Android 过滤器,改变绘图颜色
Android filter, change drawable color
所以,我想对 Android 中的一张图片应用滤镜,这张图片全是绿色,但是这种颜色有不同的色调,我想把它变成红色。现在我正在使用这个代码:
Drawable ballon = ContextCompat.getDrawable(context, R.drawable.msg_out);
ballon.setColorFilter(new
PorterDuffColorFilter(context.getResources().getColor(R.color.redLightClose), PorterDuff.Mode.MULTIPLY));
view.setBackgroundDrawable(ballon);
但结果我得到了两种颜色的褐色混合......我应该使用另一种滤镜吗?如果是这样, 你会推荐一个。
我改用 Tint,它完成了工作。
Drawable iconDrawable = ContextCompat.getDrawable(context, R.drawable.msg_out);
DrawableCompat.setTint(iconDrawable, context.getResources().getColor(R.color.primary));
setBackgroundViewCompat(text, iconDrawable);
所以,我想对 Android 中的一张图片应用滤镜,这张图片全是绿色,但是这种颜色有不同的色调,我想把它变成红色。现在我正在使用这个代码:
Drawable ballon = ContextCompat.getDrawable(context, R.drawable.msg_out);
ballon.setColorFilter(new
PorterDuffColorFilter(context.getResources().getColor(R.color.redLightClose), PorterDuff.Mode.MULTIPLY));
view.setBackgroundDrawable(ballon);
但结果我得到了两种颜色的褐色混合......我应该使用另一种滤镜吗?如果是这样, 你会推荐一个。
我改用 Tint,它完成了工作。
Drawable iconDrawable = ContextCompat.getDrawable(context, R.drawable.msg_out);
DrawableCompat.setTint(iconDrawable, context.getResources().getColor(R.color.primary));
setBackgroundViewCompat(text, iconDrawable);