ListView下方的LinearLayour不可见

San*_*osh 6 android listview

为什么只有ListView可见?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_gravity="center" android:choiceMode="singleChoice">
</ListView> 


<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
      android:gravity="center"
    android:layout_marginTop="15dp"> 

    <Button android:id="@+id/viewComplaintsMoreButton"
        android:text="  More  "  
        android:layout_width="wrap_content" android:layout_height="wrap_content" />

    <Button android:id="@+id/viewComplaintsCancelButton"
        android:text="  Cancel  "  
        android:layout_marginLeft="50dp" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

</LinearLayout> 
Run Code Online (Sandbox Code Playgroud)

Vla*_*mir 14

尝试将ListView权重设置为1

<ListView
     android:id="@+id/android:list"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:choiceMode="singleChoice"
     android:layout_weight="1">
</ListView> 
Run Code Online (Sandbox Code Playgroud)

  • @Vlad哇真的很久以前=)默认布局权重为0,布局高度设置为`wrap_content`视图不会调整大小,所以如果列表占用的空间大于可用的屏幕大小,它将不会留下其他布局的空间.将布局权重设置为1使其填充所有*可用空间*,布局权重为0的布局. (2认同)