如何使用水平不确定样式显示ContentLoadingProgressBar

4
我将尝试使用ContentLoadingProgressBar实现水平不确定样式的进度条。以下是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" />

进度条以空的水平线形式呈现,没有任何进展。 通过设置
style="?android:attr/progressBarStyleLarge"

循环不定进度显示正常。我错过了什么,我甚至尝试过


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

仍然没有运气。
1个回答

10

我知道这个问题被问了很久,但是如果有人因为同样的问题到这里来:

你只需要在你的xml中添加 android:indeterminate="true":

<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"/>
希望这有所帮助!
更新:
对于那些想要迁移到AndroidX的人,只需更新您的标签以使用。
<androidx.core.widget.ContentLoadingProgressBar
...
android:indeterminate="true"/>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接