Issue
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.
Solution
Put it outside of the ScrollView. Just have the ScrollView and the ProgressBar overlap.
You can read about how to overlap views here: Overlapping Views in Android
There's a couple of ways to do it, ranging from GridLayouts to RelativeLayouts and then programatic ways to do it.
Answered By - Alex K Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.