我有兩個列表中的LinearLayout,我希望他們能夠根據自己的內容分享它們之間的空間,機器人2列表視圖WRAP_CONTENT
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/page_vierge"
android:orientation="vertical"
android:padding="5dp">
<ListView
android:id="@+id/list_amis_fb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="0.5dp"
android:padding="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center"
android:textSize="20sp"
android:text="Amis "/>
<ListView
android:id="@+id/list_amis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="0.5dp"
android:padding="5dp" />
</LinearLayout>
看圖片
1:如果如果該列表1是小和列表2含量爲較長
2:如果如果列表2是小和列表1內容較長
3:2列表很長
在我的代碼中,當列表1很長時,列表2是不可見的!
幫助。
從不給列表視圖高度WRAP_CONTENT。它應該始終是固定高度或MATCH_PARENT以提高性能 –
,但您可以在線性佈局內採用列表視圖,並且可以輕鬆設置線性佈局的權重。 –