android - android上的不确定圆形进度条是白色的,尽管colorAccent颜色

标签 android android-5.0-lollipop material-design

我无法弄清楚如何更改 API-21 上不确定的圆形进度条的颜色。我已确保我的 colorAccent 设置正确。我的理解是系统应该从 colorAccent 中获取并相应地为 ProgressBar 着色。知道可能出了什么问题吗?

app/src/main/res/layout-v21/fragment_story_comments.xml

<ProgressBar
        android:id="@+id/progress_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="visible"/>

app/src/main/res/values/themes.xml

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowNoTitle">true</item>
</style>

app/src/main/res/values/colors.xml

<color name="colorAccent">#ff5722</color>
<color name="colorPrimary">#ff5722</color>
<color name="colorPrimaryDark">#e64a19</color>

最佳答案

注意:根据原始请求,这仅适用于 Android 5.0 (Lollipop) 及更高版本。对于较旧的 Android 版本,您必须替换 ProgressBar 的 progressDrawable。

根据 Liam 的回答,我设法使用 indeterminateTint 标志在 XML 上工作。

显然要让它工作,你需要设置 indeterminate 和 indeterminateTintMode 标志。

这个模式对我来说有点神秘。我尝试了所有这些,但只用 src_in 和 src_atop 得到了预期的结果。我不知道这些模式实际上是做什么的,所以如果有人能对此进行扩展,我将不胜感激。

在任何情况下这都应该有效:

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    android:indeterminateTint="#F00"
    android:indeterminateTintMode="src_in" />

关于android - android上的不确定圆形进度条是白色的,尽管colorAccent颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26962136/

相关文章:

android - 折叠工具栏布局,工具栏中带有 Logo 、标题、副标题

android - java.lang.VerifyError 在 2.2.2 但不是 2.3.3

android - 如何使用 BluetoothLeAdvertiser 添加特征?

android - 升级到 Lollipop 后无法测试应用程序

android - CoordinatorLayout.Behavior : how to set it programmatically

android - 如何制作跳跃标尺

android - SharedElement 在 Activity 转换中崩溃

android - 我可以更改 Android Layout Transition 的行为以消除淡入淡出但保持高度动画吗?

Android 模拟器无法在 ubuntu 中启动

安卓 5 : button underneath softnavigation bar (Showcaseview legacy)