4
我有一個頁腳的ListView的問題(我不能居中頁腳)。ListView頁腳寬度
我正在使用頁腳作爲無盡的列表。
我遇到的問題是,頁腳沒有拉伸到匹配列表寬度(而是以某種方式使用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);
這是最後的結果看起來的樣子: (我可以't張貼圖像在stackoverflow,但這裏是一個外部鏈接到圖像) http://s21.postimg.org/3zkd7pic7/listview_footer_problem.png
我試過一切中心頁腳但沒有任何工作。我希望有人能幫助我,因爲這會讓我壓力一段時間。
謝謝。
可悲的是它仍然是相同的 –
@IonutNegru我改變了代碼一點。看看它現在是否有效。 – Vikram
@IonutNegru並且,當膨脹'R.id.footer_layout'時,使用'inflate(R.layout.list_footer_load_more,null);' – Vikram