我有一个图像按钮,我希望能够将透明部分设置为一种颜色

I've got an image button and I want to be able to set the transparent parts to a color

我有一个 ImageButton:

并且我想将图像的透明部分变成另一种颜色,同时将背景保留为白色。有没有办法在 xml(或代码)中做到这一点?

我试过:

android:background="@color/colorPrimary"

android:backgroundTint="@color/colorPrimary"

但这会将整个背景更改为不同的颜色,而不是透明部分。它将透明部分留白。

使用android:tint="@color/colorPrimary"