Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android过滤器,更改可绘制颜色_Java_Android_Image_Layout_Imagefilter - Fatal编程技术网

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);