Mar*_*hov 4 markup android android-listview android-progressbar
我有一个AsyncTask中填充的ListView。在运行时,ListView变为不可见,ProgressBar显示在水平中心,在AsyncTask完成后消失,然后再次显示ListView。现在看起来像这样:

但是我需要将ProgressBar显示在ListView的内部,并且水平和垂直居中:

这是我的布局标记:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:id="@+id/LinearHeaderProgress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:id="@+id/HeaderProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
</LinearLayout>
<ListView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/listView"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我该如何实现?
谢谢。
尝试像这样使用RelativeLayout,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/HeaderProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
</ProgressBar>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1630 次 |
| 最近记录: |