【发布时间】:2013-07-24 07:01:45
【问题描述】:
列表视图的页脚有问题(我无法将页脚居中)。
我将页脚用于无限列表。
我遇到的问题是页脚没有被拉伸以匹配列表宽度(而是以某种方式使用 wrap_content)。
这是页脚布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:padding="10dp" >
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Loading more..." />
</LinearLayout>
这就是我将页脚添加到列表视图的方式:
View footerView;
...
// Get the custom layout for footer
footerView = getActivity().getLayoutInflater().
inflate(R.layout.list_footer_load_more, getListView(), false);
LinearLayout footerViewLayout = (LinearLayout) footerView.findViewById(R.id.footer_layout);
// Adding custom view to ListView at footer
getListView().addFooterView(footerViewLayout, null, false);
这就是最终结果的样子: (我无法在 stackoverflow 上发布图片,但这是图片的外部链接) http://s21.postimg.org/3zkd7pic7/listview_footer_problem.png
我尝试了一切使页脚居中但没有任何效果。我希望有人可以帮助我,因为这让我有一段时间压力很大。
谢谢。
【问题讨论】:
标签: android listview layout footer