Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show ContentLoadingProgressBar with horizontal indeterminate style

I'm trying to achieve horizontal indeterminate style of progress bar with ContentLoadingProgressBar. Below is the xml layout

 <android.support.v4.widget.ContentLoadingProgressBar
                android:id="@+id/pbar_Cloud"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:layout_gravity="bottom"
                android:visibility="visible" />

The progress bar is displayed as empty horizontal line with no progress. By setting

style="?android:attr/progressBarStyleLarge"

Circular indeterminate progress is shown fine. What am I missing, I have even tried

ContentLoadingProgressBar bar = (ContentLoadingProgressBar) findViewById(R.id.pbar_Cloud);
bar.setActivated(true);
bar.show();

Still no luck.

like image 665
Ram Kumar Avatar asked Dec 24 '22 15:12

Ram Kumar


1 Answers

I know this was asked a long time ago, but in case someone else winds up here with the same problem:

You just need to add android:indeterminate="true" to your xml:

<android.support.v4.widget.ContentLoadingProgressBar
                android:id="@+id/pbar_Cloud"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:layout_gravity="bottom"
                android:visibility="visible" 
                android:indeterminate="true"/>

hope that helps!

Update:

For those of you migrating to AndroidX just update your tag to use

<androidx.core.widget.ContentLoadingProgressBar
...
android:indeterminate="true"/>
like image 121
Michael Marsella Avatar answered May 08 '23 14:05

Michael Marsella