Android ContentLoadingProgressBar 的示例用法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20438751/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:51:48  来源:igfitidea点击:

Example usage for ContentLoadingProgressBar

androidandroid-view

提问by Lalith B

I just jumped and found this class ContentLoadingProgressBarfrom 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.

我刚刚ContentLoadingProgressBar从android的开发人员网站上跳了起来,找到了这个类。我搜索了找不到该类的任何用法或解释。我在课堂上列出了几个问题,如果有人回答就太好了。

  1. How is it different from ProgressBar ?
  2. Should we show/hide the ProgressBar ourself ?
  3. Styling the ProgressBar ?
  1. 它与 ProgressBar 有何不同?
  2. 我们应该自己显示/隐藏 ProgressBar 吗?
  3. 样式化 ProgressBar ?

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

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

回答by

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.

它适用于Android 5.0。我认为我的测试后风格很重要。

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

这个小部件的显示效果恐怕取决于你的应用程序的主题。

回答by Zharf

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

我能够让这件事对我有用,但它需要对我从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.

我删除了onAttachedToWindow()覆盖,因为我觉得在这种情况下没有必要删除回调。重写的方法调用引起show()onResume()不工作,因为在回调后进行正确的去除。

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 ProgressBarconstructors so I changed the constructors to call the ProgressBarconstructors directly without modifying the arguments.

我还必须弄清楚为什么视图显然根本没有被绘制,我认为原因是传递给ProgressBar构造函数的第三个参数,所以我更改了构造函数以ProgressBar直接调用构造函数而不修改参数。

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
  1. 如果在 show() 之后调用 hide() 不到 0.5 秒,它根本不会显示,并且显示至少 0.5 秒,这可以防止您在“幼稚”实现中可能看到的非常快速的闪烁内容。
  2. 是的
  3. 我认为这只是一个常规的造型案例 ProgressBar