我的关闭按钮有一个标准矢量资源。关闭按钮在整个应用程序中以白色使用,因此我不能只更改填充颜色。我需要黑色的,但我被告知要重复使用白色的,然后将其染成黑色。这是 ImageButton 的 src 资源,并且任何色调都不起作用 - 例如 app:backgroundTint="@color/black" 只会使所有内容变黑。有没有人找到办法做到这一点?
这是矢量资源:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M13.414,12L19.778,18.364L18.364,19.778L12,13.414L5.636,19.778L4.222,18.364L10.586,12L4.222,5.636L5.636,4.222L12,10.586L18.364,4.222L19.778,5.636L13.414,12Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
我正在尝试在这里产生连锁反应:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/white">
<item>
<shape android:shape="oval">
<solid android:color="@color/white" />
</shape>
</item>
<item
android:bottom="4dp"
android:drawable="@drawable/ic_bk_close"
android:left="4dp"
android:right="4dp"
android:top="4dp" />
</ripple>
这是图像按钮
<ImageButton
android:id="@+id/btn_exit"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp"
android:adjustViewBounds="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/cd_exit"
android:scaleType="fitCenter"
android:src="@drawable/stim_viewer_btn_close"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
我想使用这个可能会有所帮助:
android:tint="@color/red"