布局文件如下
<?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:background="#ffffff"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Building"/>
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:layout_margin="18dp">
</ListView>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text= "@string/OK">
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Building"/>
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:layout_margin="18dp">
</ListView>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/Cancel" />
</LinearLayout>
</LinearLayout>
提示"Nested weights are bad for performance",貌似嵌套的layout_weight不可以用!