我有两个列表中的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以提高性能 –
,但您可以在线性布局内采用列表视图,并且可以轻松设置线性布局的权重。 –