我有一个应用程序,我可以找到蓝牙设备。当我开始搜索时,会出现一个对话窗口,在上方显示,配对设备及其下方显示新发现的设备。对话窗口布局上的权重
这个窗口和蓝牙聊天的例子是一样的,我从那里得到它。
会发生什么情况是,如果您有几个配对的设备,新设备的空间会变得非常小。
这是该对话窗口中的代码:我用这个代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/title_paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_paired_devices"
android:textIsSelectable="true"
android:visibility="gone"
android:background="#666"
android:textColor="#fff"
android:paddingLeft="5dp" />
<ListView android:id="@+id/paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:layout_weight="1"/>
<TextView android:id="@+id/title_new_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_other_devices"
android:textIsSelectable="true"
android:visibility="gone"
android:background="#666"
android:textColor="#fff"
android:paddingLeft="5dp"/>
<ListView android:id="@+id/new_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:layout_weight="2"/>
<Button android:id="@+id/button_scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_scan"/>
根据设备高度将屏幕分为两部分,并在运行时设置列表视图的高度 – Meenal
或者您可以使用可扩展的'ListView'。 –
@Meenal夏尔马我该怎么做? – masmic