如何通过xml ui组件更改进度条的颜色

问题描述

我有一个进度条,它以垂直方式设置样式,您可以在下面的drawable中看到

progress_verticle.xml


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@android:id/background"
        android:drawable="@color/transparent" />

    <item android:id="@android:id/progress">
        <scale
            android:scaleWidth="0%"
            android:scaleHeight="100%"
            android:scaleGravity="bottom">
            <shape>
                <solid android:color="@color/logoDark" />
                <corners
                    android:topLefTradius="1dp"
                    android:topRighTradius="1dp" />
            </shape>
        </scale>
    </item>
</layer-list>

然后我以下面的方式在xml中使用它

<ProgressBar
                android:id="@+id/idBrightnessControll"
                style="@android:style/Widget.ProgressBar.Horizontal"
                android:layout_width="20dp"
                android:layout_height="150dp"
                android:layout_margin="30dp"
                android:background="@color/bgblue"
                android:max="15"
                android:progress="1"
                android:progressDrawable="@drawable/progress_verticle"
                android:scaleWidth="0%"
                android:scaleHeight="100%"
                android:scaleGravity="bottom"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

现在,我还需要一个进度条,但是我不喜欢更改颜色"@color/logoDark"

因此,当前我要再创建一个progress_verticle_1.xml,并将其颜色更改为具有不同颜色的不同进度条。

是否可以在xml本身中更改进度栏颜色,从而避免创建多个drawable文件

编辑:-

我应该得到这个

enter image description here

但是我得到这个

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...