zhanghai/MaterialProgressBar

ProgressBar has Gingerbread-style if not using indeterminate mode

Dan1ve opened this issue · 3 comments

Hi,
I'm currently testing this library, and overall, it seems to work fine.
However, I run into an issue I could not resolve:
When I use the MaterialProgressBar on Android 4.4 with an indeterminate style and later switch to a determinate mode (indeterminate = false), the style of the ProgressBar gets a really weird look (Gingerbread?).

XML:

<me.zhanghai.android.materialprogressbar.MaterialProgressBar
                    android:id="@+id/progress_bar_download"
                    style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
                    app:mpb_progressStyle="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_weight="1"
                    android:indeterminate="true"
                    android:max="100"
                    android:paddingBottom="8dp"
                    android:paddingTop="8dp" />

and then in code (under certain circumstances) I call:

progressBar.setIndeterminate(false);
progressBar.setProgress(<some_int_value>);

Result:

image

Am I missing something here? Note that the indeterminate styling works flawlessly.

Thanks,
Daniel

I think I figured it out now:

progressBar.setIndeterminate(false);
progressBar.setProgressDrawable(new HorizontalProgressDrawable(this));
progressBar.setProgress(50);

Can you confirm this is the right way to handle changes of the indeterminate-mode at runtime?

Best,
Daniel

Quoting READNE:

app:mpb_setBothDrawables: Whether both determinate and indeterminate drawables should be set on this progress bar. Defaults to false.

You need to set it to true if you need both of the drawables, and this is so-designed because each backported drawable has some runtime cost.

Even though I did read that section, its meaning wasn't 100% clear to me.
Thanks for clarifying! 👍