我有两个清单。一个列表显示可用列表中的所有可用项目 (lv_available_items),第二个仅显示选定项目 (lv_selected_items)。我还希望所选列表占据最多 50% 的显示,为此我使用属性“layout_weight”。但是,如果它只是从可用列表中选择的一项,则它不会完全显示在所选列表中。为什么?
警报对话框的视图:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1" >
<ListView
android:id="@+id/lv_selected_items"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:background="@android:color/darker_gray">
</ListView>
<ListView
android:id="@+id/lv_available_items"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5" >
</ListView>
</LinearLayout>
这两个列表的行:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical" >
<CheckBox
android:id="@+id/cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClickRow"/>
</LinearLayout>
</LinearLayout>
截图: