ContentLoadingProgressBar中的默认颜色更改

时间:2019-04-16 10:32:53

标签: android progress-bar androidx

我在项目中使用 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 个答案:

答案 0 :(得分:1)

您需要同时设置 style android: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>

答案 1 :(得分:0)

扩展默认主题并覆盖colorAccent

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

在Android:theme属性中添加ContentLoadingProgressBar:

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