20

I just found the ContentLoadingProgressBar class from the Android developer site. I searched but couldn't find any usage or explanation for the class. I've listed down a few questions on the class and it would be great if someone answers them.

  1. How is it different from ProgressBar?
  2. Should we show/hide the ProgressBar ourself?
  3. Styling the ProgressBar?

https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar.html

Pang
  • 9,564
  • 146
  • 81
  • 122
Lalith B
  • 11,843
  • 6
  • 29
  • 47
  • Similar: https://stackoverflow.com/questions/41628693/practical-usage-of-contentloadingprogressbar – Pang Jan 10 '23 at 08:29

2 Answers2

40

I had tried this :

<android.support.v4.widget.ContentLoadingProgressBar
        android:id="@+id/address_looking_up"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:visibility="visible" />

And it works on Android 5.0. I think the style matters after my test.

And the display effect of this widget depends on the Theme of your App, I'm afraid.

Dan Dar3
  • 1,199
  • 13
  • 23
  • 6
    `style="?android:attr/?android:attr/progressBarStyleLarge"` has a typo and should be `style="?android:attr/progressBarStyleLarge"` – Yoraco Gonzales Jul 09 '15 at 18:02
7

I was able to make this thing work for me but it required some modifications to the source code which I grabbed from grepcode.

I removed the onAttachedToWindow() override, because I felt that it was unnecessary to remove the callbacks in this case. The overridden method caused calling show() in onResume() to not work because the callbacks were removed right after that.

I also had to figure out why the view apparently wasn't being drawn at all, I think the cause was the third argument passed to ProgressBar constructors so I changed the constructors to call the ProgressBar constructors directly without modifying the arguments.

My version of this class can be found here

My answers:

  1. It doesn't show at all if hide() is called less than 0.5s after show(), and it shows for at least 0.5s, this prevents very fast flickering stuff that you might see with "naive" implementations.
  2. Yes
  3. I think this is just a regular case of styling a ProgressBar
Zharf
  • 2,638
  • 25
  • 26