如何在android布局中创建固定页脚? [英] How to create fixed footer in android layout?
问题描述
我正在使用以下代码在活动底部显示按钮.
I am using following code to display button at the bottom of activity.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
>
<Button android:id="@+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
/>
</RelativeLayout>
和它上面的列表视图.当我在列表视图中显示更多数据时,此按钮面板向下移动.有人可以指导我如何在活动底部修复它吗?
and listview above it. when i display more data in listview this button pannel is moved down.can any one guide me how can i fix it at the bottom of activity?
任何帮助将不胜感激.
推荐答案
android:layout_alignParentBottom
属性必须在 RelativeLayout
的元素中声明,而不是在 RelativeLayout
自己(除非有另一个 RelativeLayout
作为父级).
The android:layout_alignParentBottom
attribute has to be declared in an element of the RelativeLayout
not in the RelativeLayout
himself (unless there is another RelativeLayout
as a parent).
你应该做这样的事情,在 RelativeLayout
中的 ListView
也:
You should do something like this, with the ListView
inside the RelativeLayout
also :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ListView ...>
<Button android:id="@+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
android:layout_alignParentBottom="true" />
</RelativeLayout>
这篇关于如何在android布局中创建固定页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!