【问题标题】:Android 'busy spinner' (progress bar) not taking colorAndroid“忙碌的微调器”(进度条)没有颜色
【发布时间】:2016-02-07 19:49:06
【问题描述】:

我已按照示例 here 尝试创建一个“忙碌”的旋转进度轮。

旋转器的外观在busy_spinner.xml中定义如下:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360">

    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:tint="#0000FF"
        android:thicknessRatio="7.0">

        <gradient
            android:angle="0"
            android:centerColor="#0000FF"
            android:endColor="#9999FF"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

它包含在我的布局文件中,如下所示:

 <ProgressBar
                        android:id="@+id/working_bluebadgeparking_reachable"
                        style="?android:attr/progressBarStyleLarge"
                        android:layout_width="24dp"
                        android:layout_height="24dp"
                        android:visibility="gone"
                        android:progressDrawable="@drawable/busy_spinner" />

以编程方式打开和关闭可见性,除了微调器是红色的之外,一切看起来都很好!

正如您在busy_spinner.xml 中看到的,我已将微调器定义为漂亮的蓝色渐变,但颜色不起作用。

【问题讨论】:

  • 这是在 Lollipop HTC One 和最新的 Nexus 5 Rom 上的模拟器中。

标签: android android-layout android-progressbar


【解决方案1】:

您为进度不确定的 ProgressBar 设置了错误的属性。

要将可绘制对象设置为不确定的进度,请使用indeterminateDrawable 属性。您正在做的是将可绘制对象设置为确定的进度,这通常是一个从 0 到 100% 水平进度的条。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-26
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-06
    相关资源
    最近更新 更多