gpt4 book ai didi

android - 当列表项很少时,如何将页脚 View 显示到屏幕末尾?

转载 作者:行者123 更新时间:2023-12-05 00:07:26 25 4
gpt4 key购买 nike

我想在 ListView 中添加页脚。当列表项的数量更多时,页脚可以正常工作。但是当 listview 的项目很少时,页脚会显示在屏幕中间,就在 listview 的下方。看起来很破旧。在这种情况下,我希望页脚与父底部对齐。谢谢你的期待。

最佳答案

这是您想要的最简单示例。你可以自定义它:

<?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"

关于android - 当列表项很少时,如何将页脚 View 显示到屏幕末尾?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20921150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com