内容加载进度条(ContentLoadingProgressBar)的默认颜色更改

3

我在我的项目中使用 androidx,并且某些地方我正在使用 ContentLoadingProgressBar,但我无法更改默认颜色。

我尝试使用 android:indeterminateTint,但没有帮助。

如果有人对此有任何想法,请建议。

<androidx.core.widget.ContentLoadingProgressBar
                android:id="@+id/progress"
                android:layout_width="@dimen/_30sdp"
                android:layout_height="@dimen/_30sdp"
                android:indeterminateTint="@android:color/white"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
2个回答

7

扩展默认主题并覆盖colorAccent

<style name="AppTheme.WhiteAccent">
    <item name="colorAccent">@color/white</item> <!-- Whatever color you want-->
</style>

添加ContentLoadingProgressBar,使用android:theme属性:

android:theme="@style/AppTheme.WhiteAccent"

2

您需要同时设置 styleandroid:theme,并指定您想要的进度条强调颜色。请参考以下代码片段:

layout.xml

 <androidx.core.widget.ContentLoadingProgressBar
        android:theme="@style/ContentLoadingProgress"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        />

styles.xml

  <style name="ContentLoadingProgress">
    <item name="colorAccent">@color/colorWhite</item>
  </style>

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