【发布时间】:2011-10-05 12:54:11
【问题描述】:
我试图让 ProgressBar 和 TextView 在 ViewSwitcher 中居中。它们可以垂直放置在彼此上方,尽管如果它们水平居中并排在一起我没有问题。我能够让它们水平居中但不能垂直居中。尽管每个父视图都有 android:layout_height="fill_parent"
,但外部视图(ViewSwitcher)的高度似乎没有垂直填充这里是xml:
<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loadSwitcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#ff000000">
<ProgressBar
android:indeterminate="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/marker_progress"
style="?android:attr/progressBarStyle"
android:gravity="center_vertical" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="18sp"
android:text="Loading data..."
android:gravity="center" />
</LinearLayout>
<ListView
android:id="@+id/android:appCategoriesList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff918e8e"
android:divider="#ff000000"
android:dividerHeight="1dp"
android:cacheColorHint="#00000000"
android:scrollingCache="true"
android:clickable="false"
android:focusable="false" />
</ViewSwitcher>
【问题讨论】: