I have a ProgressBar in a ScrollView, and I'd like it to stay centered vertically despite the user scrolling down or up. However, I'm not sure how to accomplish this.
Here's the code that I have, simple as it is. I have an indeterminate ProgressBar:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ocr_scroll_view"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="@+id/image_holder"
android:layout_gravity="end"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ProgressBar android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:visibility="gone"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
And I call it as such:
spinningProgressBar = (ProgressBar)findViewById(R.id.progressBar1);
spinningProgressBar.setIndeterminate(true);
spinningProgressBar.setVisibility(View.GONE);
Setting its visibility at the appropriate times.
All suggestions very much appreciated.