我有一個包含TableLayout的ScrollView。當一個AsyncTask完成爲我提取數據時,tablelayout以編程方式激活。然後,方法根據返回的數據量構建TableRows並將它們附加到TableLayout。Center Vert。 &Horiz。 TableLayout中的ProgressBar?
在XML中,TableLayout中的唯一項是ProgressBar。這裏的XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/electionsScrollView" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableLayout android:id="@+id/electionsQuestionContainer"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ProgressBar android:id="@+id/electionsProgressBar"
style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_gravity="center_vertical|center_horizontal" />
</TableLayout>
</ScrollView>
我顯然不能把進度右側滾動視圖中,作爲滾動視圖只能承載一個項目(tablelayout)。我想我不希望將ProgressBar放置在表格行中,因爲我認爲這比移除progressBar.setVisibility(View.GONE);的AsyncTask會更麻煩。所以tableRow是我唯一的選擇,還是有一個原因,爲什麼我的ProgressBar不是在屏幕中間垂直和水平居中?