2
我已經創建了以下佈局,其中UI由兩個LinearLayouts組成,每個人都有一個標題textview和一個列表視圖。我需要動態設置ListView高度,以便正確顯示。Android的兩個ListViews間距和佈局
現在是這樣的權利:
看空間如何空浪費了第一個ListView控件下方,而另一人顯示滾動條和能夠受益多餘的空間?
佈局XML看起來是這樣的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Current outages"
android:paddingLeft="3sp"
android:background="@color/listHeader_Background"
android:textColor="@color/listHeader_Foreground"/>
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingLeft="3sp"
android:text="Resolved outages"
android:background="@color/listHeader_Background"
android:textColor="@color/listHeader_Foreground"/>
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
如果在包含ListView項目的LinearLayouts上設置'android:layout_height =「wrap_content」'不應該根據佈局的大小收縮嗎? – 2011-03-17 13:41:58