Reputation: 466
I am trying to achieve the following progress dialog (without the text)
My current XML code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
>
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:visibility="gone"
/>
I am programatically hiding and showing the progress bar when required (and hiding/showing other screen elements), all of which are under the Relative Layout in the XML code above.
However, whenever the Progress Bar shows, it appears centered at the top of the screen instead of being centered horizontally AND vertically.
Upvotes: 0
Views: 866
Reputation: 774
Setting the ScrollView's attribute "fillViewport" to true should do it.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:orientation="vertical"
android:fillViewport="true"
>
also make sure its child's height is set to "fill_parent" and the ProgressBar is properly centered
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
Upvotes: 2