求助各位,我想在一个Listview列表的下方添加一个"更多"的按钮,以便进行Listview列表的扩展,但是试了很多的布局,在Listview下方添加的Button都显示不出来,求助各位,下面是我的整个XML配置文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:text="话题"
android:background ="#B0E2FF"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"
>
</TextView>
<Button
android:id="@+id/refresh"
android:layout_toLeftOf="@id/title"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:text="刷新"
/><ListView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/users"
android:layout_below="@id/refresh"
>
</ListView><Button
android:id="@+id/more"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="更多"
android:layout_below="@id/users"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:text="话题"
android:background ="#B0E2FF"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"
>
</TextView>
<Button
android:id="@+id/refresh"
android:layout_toLeftOf="@id/title"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:text="刷新"
/><ListView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/users"
android:layout_below="@id/refresh"
>
</ListView><Button
android:id="@+id/more"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="更多"
android:layout_below="@id/users"
/>
</RelativeLayout>
你第二个控件
android:layout_toLeftOf="@id/title"
android:layout_alignParentRight="true"
看着不矛盾么。另外listView充满父view。 会导致 “更多”显示不出来
。<Button
android:id="@+id/more"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="更多"
android:layout_alignParentBottom="true"
/>
<ListView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/users"
android:layout_below="@id/refresh"
android:layout_above="@id/more"
>
改成这样子就可以了需要记住。 xml文件时从上往下解析
先定义的view 系统会先分配指定大小layout_height layout_width的空间
如果没空间了。后定义的肯定显示不出来了
要么用绝对布局方式,把listview大小调整了。
要么就像楼上的方式搞。
如果用RelativeLayout 如果你button布局写的是居于最底部 那么就会挡住listview中的内容