ContentLoadingProgressBar 的实际使用
Practical usage of ContentLoadingProgressBar
我在浏览 android 的开发者网站时发现了一个名为 ContentLoadingProgressBar 的 class。看到这个class,我心里想出了一些问题。如果有人回答我的问题就太好了。
- 普通
ProgressBar
和 ContentLoadingProgressbar
有什么区别?
- ContentLoadingProgressBar 的实际用法是什么?
我们可以show/hide这个进度条按照我们的要求吗?
如何自定义此进度条的样式?
感谢您的提前帮助。如果有人使用代码和示例对其进行解释,那就太好了。谢谢。
这是我的答案!
What is the difference between Normal ProgressBar and
ContentLoadingProgressbar?
ContentLoadingProgressbar
在显示使用 hide()
之前等待最短时间被解雇,例如 with-in 0.5 seconds.So 即使 show()
被调用也可以被解雇在它出现在屏幕上之前。
What is the practical usage of ContentLoadingProgressBar
它可以防止您在 "naive" 实现中看到的非常快速的闪烁。
Can we show/hide this progressbar according to our requirement
是
How can I custom style this progressBar
<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" />
将样式替换为 android:theme
根据 docs :
ContentLoadingProgressBar implements a ProgressBar that waits a minimum time to be dismissed before showing. Once visible, the progress bar will be visible for a minimum amount of time to avoid "flashes" in the UI when an event could take a largely variable time to complete (from none, to a user perceivable amount)
这清楚地表明它与常规 ProgressBar
没有区别。此外,准确地说,这是一个 UI 调整。也就是说,如果 hide()
在执行 show()
后不到 0.5s
被调用,则 ContentLoadingProgressBar
不会显示,从而防止 UI
中的快速闪烁。希望能帮助到你。
假设您要为某些后台操作显示 ProgressBar,该操作可能需要不到 500 毫秒或超过 5 秒。
你调用progressBar.show()
然后开始你的后台操作
如果你的后台运行在500ms以内结束。然后你调用 progressBar.hide()
现在,用户将看到进度条在几分之一秒内出现和消失的闪烁。
介绍 ContentLoadingProgressBar:
当您使用这个进度条时,它会在显示进度对话框之前等待最短时间。这意味着如果 show()
调用和 hide()
调用之间的时间小于该最短时间,则不会向用户显示任何对话框。
关于将 ContentLoadingProgressBar 用于 recyclerview 项目的注意事项。我有一个场景,其中任意 RV 项目可以在单击时下载某些内容,并在完成之前显示不确定的进度。在这种情况下似乎不可能使用 CLPB 的好处,因为在显示()/隐藏()时在 CLPB 中保持内部延迟它:重用的视图可能具有不一致的进度状态(进度消失或变得无限取决于重用的持有者视图状态).因此我被迫 return 旧的好 setVisibility:
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position)
...
if (item.isLoading()) {
//holder.progressBar.show();
holder.progressBar.setVisibility(View.VISIBLE);
} else {
//holder.progressBar.hide();
holder.progressBar.setVisibility(View.INVISIBLE);
}
我在浏览 android 的开发者网站时发现了一个名为 ContentLoadingProgressBar 的 class。看到这个class,我心里想出了一些问题。如果有人回答我的问题就太好了。
- 普通
ProgressBar
和ContentLoadingProgressbar
有什么区别? - ContentLoadingProgressBar 的实际用法是什么?
我们可以show/hide这个进度条按照我们的要求吗?
如何自定义此进度条的样式?
感谢您的提前帮助。如果有人使用代码和示例对其进行解释,那就太好了。谢谢。
这是我的答案!
What is the difference between Normal ProgressBar and ContentLoadingProgressbar?
ContentLoadingProgressbar
在显示使用 hide()
之前等待最短时间被解雇,例如 with-in 0.5 seconds.So 即使 show()
被调用也可以被解雇在它出现在屏幕上之前。
What is the practical usage of ContentLoadingProgressBar
它可以防止您在 "naive" 实现中看到的非常快速的闪烁。
Can we show/hide this progressbar according to our requirement
是
How can I custom style this progressBar
<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" />
将样式替换为 android:theme
根据 docs :
ContentLoadingProgressBar implements a ProgressBar that waits a minimum time to be dismissed before showing. Once visible, the progress bar will be visible for a minimum amount of time to avoid "flashes" in the UI when an event could take a largely variable time to complete (from none, to a user perceivable amount)
这清楚地表明它与常规 ProgressBar
没有区别。此外,准确地说,这是一个 UI 调整。也就是说,如果 hide()
在执行 show()
后不到 0.5s
被调用,则 ContentLoadingProgressBar
不会显示,从而防止 UI
中的快速闪烁。希望能帮助到你。
假设您要为某些后台操作显示 ProgressBar,该操作可能需要不到 500 毫秒或超过 5 秒。
你调用
progressBar.show()
然后开始你的后台操作如果你的后台运行在500ms以内结束。然后你调用
progressBar.hide()
现在,用户将看到进度条在几分之一秒内出现和消失的闪烁。
介绍 ContentLoadingProgressBar:
当您使用这个进度条时,它会在显示进度对话框之前等待最短时间。这意味着如果 show()
调用和 hide()
调用之间的时间小于该最短时间,则不会向用户显示任何对话框。
关于将 ContentLoadingProgressBar 用于 recyclerview 项目的注意事项。我有一个场景,其中任意 RV 项目可以在单击时下载某些内容,并在完成之前显示不确定的进度。在这种情况下似乎不可能使用 CLPB 的好处,因为在显示()/隐藏()时在 CLPB 中保持内部延迟它:重用的视图可能具有不一致的进度状态(进度消失或变得无限取决于重用的持有者视图状态).因此我被迫 return 旧的好 setVisibility:
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position)
...
if (item.isLoading()) {
//holder.progressBar.show();
holder.progressBar.setVisibility(View.VISIBLE);
} else {
//holder.progressBar.hide();
holder.progressBar.setVisibility(View.INVISIBLE);
}