使用 Material Design Android 库更改可绘制颜色

Change drawable color with Material Design Android library

我在我的 drawable 文件夹中创建了一个矢量资源,并在其 xml 文件中将其颜色更改为 #155724。但是每当我尝试将此 drawable 添加到我的 button 时,我的可绘制对象总是选择我在 colors.xml 文件中声明的 primaryColor。请注意,我正在使用 material-design 库。

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="#155724"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="#155724"
        android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
</vector>

这就是我在按钮中添加可绘制对象的方式:

<Button
                android:id="@+id/doneBtn"
                style="@style/Widget.MaterialComponents.Button.OutlinedButton.Icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/done"
                android:textColor="#155724"
                app:icon="@drawable/ic_baseline_check_circle_24"
                app:strokeColor="#155724" />

将此属性添加到按钮,因为默认属性是 colorPrimary

app:iconTint="@color/yourColor"