Java Android过滤器,更改可绘制颜色
所以,我想对安卓系统中的一幅图像应用一个过滤器,这幅图像都是绿色的,但色调不同,我想把它变成红色。现在我正在使用以下代码:Java Android过滤器,更改可绘制颜色,java,android,image,layout,imagefilter,Java,Android,Image,Layout,Imagefilter,所以,我想对安卓系统中的一幅图像应用一个过滤器,这幅图像都是绿色的,但色调不同,我想把它变成红色。现在我正在使用以下代码: Drawable ballon = ContextCompat.getDrawable(context, R.drawable.msg_out); ballon.setColorFilter(new PorterDuffColorFilter(context.getResources().getColor(R.color.re
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);
但结果我得到了两种颜色的棕色混合。。。我应该使用另一种过滤器吗?如果是这样的话,你会推荐女巫一号。我改用了色调,效果很好
Drawable iconDrawable = ContextCompat.getDrawable(context, R.drawable.msg_out);
DrawableCompat.setTint(iconDrawable, context.getResources().getColor(R.color.primary));
setBackgroundViewCompat(text, iconDrawable);
我改用了淡色,效果很好
Drawable iconDrawable = ContextCompat.getDrawable(context, R.drawable.msg_out);
DrawableCompat.setTint(iconDrawable, context.getResources().getColor(R.color.primary));
setBackgroundViewCompat(text, iconDrawable);