Example usage for ContentLoadingProgressBar

梦想的初衷 提交于 2020-01-01 01:44:13

问题


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

  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


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/20438751/example-usage-for-contentloadingprogressbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!