Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android progress bar is always indeterminate on changing its style to progressBarStyleInverse from progressBarStyleHorizontal

Tags:

android

xml

I am trying to place a circular progress bar, start it initially in indeterminate mode and as soon as the download starts and progress is available convert it to determinate mode and set its progress. Code works absolutely fine when using style progressBarStyleHorizontal and as soon as I change it to progressBarStyleInverse setting the progress has no effect. Progress bar starts indeterminate and continues for ever the same.

What surprised me is on setting android:indeterminate=false in xml also has no effect.

Here is the declaration of progress bar in xml

<ProgressBar
                    style="?android:attr/progressBarStyleHorizontal"
                    android:indeterminate="false"
                    android:layout_gravity = "center"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"/>

This is how am updating my progress bar progress. Obviously I have an id to it I have removed it in xml pasted. I have the reference of progress bar which I got using findViewById.(Reference to progress bar is not an issue, if you are thinking thats the issue)

holder.progressbar.setIndeterminate(false);
holder.progressbar.invalidate();
holder.progressbar.setProgress(/*value */);

What mistake am I making?? Please help. I wasted almost 5 hours on this issue. Please help.

Thanks in advance.

like image 838
Sandeep Bhandari Avatar asked Feb 21 '16 19:02

Sandeep Bhandari


1 Answers

The trick is that you need to use style="?android:attr/progressBarStyleHorizontal" even though it's a circular ProgressBar. And set a circular drawable as a progress drawable.

Refer to this question :

Android Circular Determinate ProgressBar

like image 135
zCode93 Avatar answered Nov 14 '22 21:11

zCode93