I use the following line to change the color of a VectorDrawable:
mydrawable.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
Thi
Try this:
public class MyDrawableCompat {
public static void setColorFilter(@NonNull Drawable drawable, @ColorInt int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
drawable.setColorFilter(new BlendModeColorFilter(color, BlendMode.SRC_ATOP));
} else {
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
}
}
And this:
MyDrawableCompat.setColorFilter(mydrawable.getBackground(), color);