如何设置一个页脚在Android的ListView动态舒展的底部? [英] How can I set a footer in an android listview to dynamically stretch to the bottom?
问题描述
我搜索已可惜没有找到真正的解决了这一点。我添加了一个注脚到ListView有:
I searched already but unfortunately found no real solution to this. I have added a footer to a listview with:
View footer = getLayoutInflater().inflate(R.layout.listfooter, null);
listview.addFooterView(footer);
页脚的XML看起来是这样的:
The xml for the footer looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFFFF"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:background="#ee222222"
>
<TextView
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Test Test Test"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
它确实显示页脚只为单行
It does display a footer only as a single line
我改变动态列表中的行数,但我想页脚总是填充列表视图的其余部分是否有它没有足够的项目。
I change the number of rows in the list dynamically but I want the footer to always fill the rest of the listview if there are not enough items in it.
我怎样才能做到这一点?
How can I do this?
编辑:我添加了一个图像,左侧是怎么回事,现在和右边的2是我想要的。
I added an image, the left is how it is right now and the 2 on the right is what I want.
推荐答案
我可以说,最好的解决方案可以为这个问题。
I can say the best solution can be for this problem is.
1)创建其中必须有层次这样的XML布局。
1) Create a XMl layout which must have hierarchy like this.
<Liniear Layout>
<ScrollView>
<LinearLayout>
<ListView>// add your list data here.
<\ListView>
<TextView><TextView>// for footer text
<\LinearLayout>
<ScrollView>
<LinearLayout>
请让我硝酸钾如果有的话,我希望这种做法会工作,我没有尝试过自己。
Please let me kno if anything, I hope this approach will work as I tried it myself.
这篇关于如何设置一个页脚在Android的ListView动态舒展的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!