我想向列表视图添加页脚。当列表项数量较多时,页脚效果很好。
但是当列表视图的项目很少时,页脚会显示在屏幕中间,就在列表视图的下方。这看起来很破旧。在这种情况下,我希望页脚与父底部对齐。
谢谢你的期待。
这是你想要的最简单的例子。你可以自定义它:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:id="@+id/footer" >
</RelativeLayout>
</RelativeLayout>
如果你想这样做,你在评论中说,你必须在代码中设置页脚的布局参数,你必须获取列表的大小,然后获取屏幕中显示的行数,然后
if (listSize < numRow)
//set footer to bottom of your list
else
// android:layout_alignParentBottom="true"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)