问题描述
|
我试图将ProgressBar视图放在ListActivity的ListView下方。我希望它始终在listView的最后一行之下。
只要列表(在运行时由适配器填充)列表不超过屏幕,就不会出现放置在LinearLayout中的ProgressBar。一旦列表大于屏幕,进度条将不再可见。
布局xml如下所示:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:id=\"@+id/db1_root\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:orientation=\"vertical\">
<!-- Title bar -->
<LinearLayout
style=\"@style/TitleBar\" >
<TextView
style=\"@style/TitleBarText\"
android:text=\"Some title text\" />
<ImageButton
style=\"@style/TitleBaraction\"
android:contentDescription=\"@string/description_search\"
android:src=\"@drawable/title_search\" />
</LinearLayout>
<!-- Content -->
<LinearLayout
android:layout_height=\"wrap_content\"
android:layout_width=\"fill_parent\" >
<ListView
android:divider=\"@drawable/category_item_divider\"
android:dividerHeight=\"@dimen/list_divider_height\"
android:layout_height=\"wrap_content\"
android:id=\"@+id/android:list\"
android:layout_width=\"fill_parent\"
android:layout_weight=\"1\" />
<TextView
android:id=\"@+id/android:empty\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:text=\"@string/category_no_items\" />
</LinearLayout>
<!-- Progress bar -->
<LinearLayout
android:layout_height=\"wrap_content\"
android:layout_width=\"wrap_content\" >
<ProgressBar
android:id=\"@+id/productlist_progressbar\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\" />
</LinearLayout>
</LinearLayout>
使用LinearLayout不可能吗?任何帮助表示赞赏。
解决方法
您应该使用添加页脚:
list.addFooterView(footerView);
或手动进行,但随后考虑使用相对布局,则比线性布局要强大得多。然后将页脚放在列表下方,或者最好将列表和空白视图放在页脚视图上方。