我已经按照这个例子做了 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 中看到的那样,我已将微调器定义为漂亮的蓝色渐变,但颜色不起作用。
最佳答案
您为进度不确定的 ProgressBar 设置了错误的属性。
要为不确定的进度设置可绘制对象,请使用 indeterminateDrawable属性(property)。您正在做的是为确定进度设置可绘制对象,这通常是一个从 0 到 100% 的水平进度条。
关于Android 'busy spinner'(进度条)不上色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35258252/