Android 'busy spinner'(进度条)不取色
Android 'busy spinner' (progress bar) not taking color
我按照示例 here 尝试创建一个 'busy' 旋转进度轮。
旋转器的外观在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 属性。您正在做的是为确定进度设置可绘制对象,这通常是一个从 0 到 100% 的水平进度条。
我按照示例 here 尝试创建一个 'busy' 旋转进度轮。
旋转器的外观在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 属性。您正在做的是为确定进度设置可绘制对象,这通常是一个从 0 到 100% 的水平进度条。