我想在手机屏幕上用listview显示一些列表信息,然后再在屏幕下端添加一个按钮,方便执行删除部分列表信息操作,可是运行结果只能显示listview内容,不能显示按钮,我还特意加了背景方便查看,可是背景设置也不能显示。一下是layout的xml
<?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:orientation="vertical" >    <LinearLayout
        android:id="@+id/listlinearLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="10"
        android:orientation="horizontal"
        android:background="#aa0000" >        <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="true"
            android:background="#0000aa"
            android:scrollbars="vertical" /> <!-- scrollbars 滚动条 -->
    </LinearLayout>    <LinearLayout
        android:id="@+id/listviewlinearLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:background="#00aa00" >        <button
            android:id="@+id/deletebutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ffffffff"
            android:text="@string/deletebutton" />
    </LinearLayout></LinearLayout>

解决方案 »

  1.   

    先把layout_weight都设置成1看看,没问题的话就是设置的10:1太大了
    还有,你里面包的那两个linear layout根本没必要,都去掉,应该就没问题了
      

  2.   

     android:layout_height="fill_parent"-》android:layout_height="wrap_content"
      

  3.   

    用RelativeLayout相对布局,ListView设置为top,Button设置成Bottom显示。
      

  4.   

    最简单方法 将listview外边的 linnerLayout 去掉 然后将listView 的权重设为1 别的不动 就好了
      

  5.   

    大哥 你个button标签写错了  是第一个字母要大写一下代码:
    <?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:orientation="vertical" >  <LinearLayout
      android:id="@+id/listlinearLayout"
      android:layout_width="fill_parent"
      android:layout_height="0dp"
      android:layout_weight="10"
      android:orientation="horizontal"
      android:background="#aa0000" >  <ListView
      android:id="@+id/android:list"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:drawSelectorOnTop="true"
      android:background="#0000aa"
      />
      </LinearLayout>  <LinearLayout
      android:id="@+id/listviewlinearLayout"
      android:layout_width="fill_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:gravity="center_horizontal"
      android:orientation="vertical"
      >
        
      <Button
      android:id="@+id/deletebutton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="删除按钮" />
      </LinearLayout></LinearLayout>
      

  6.   

    RelativeLayout是最好的布局,速度快。按钮设置位于地步,ListView相对按钮上面,不贴码了。绝对好用
      

  7.   

    各位大哥大姐们,你们说的方法我都用过了,可是还是不行。如果listview是空的话,可以显示,很怪。以下是我最新布局。
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/listlinearLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#aa0000"
        android:orientation="vertical" >
        
        <Button
            android:id="@+id/deletebutton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ffffffff"
            android:text="@string/deletebutton" />    <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#0000aa"
            android:drawSelectorOnTop="false"
            android:scrollbars="vertical" /> <!-- scrollbars 滚动条 --></LinearLayout>