Creating a PorterDuff ColorFilter
suggest changePorterDuff.Mode
is used to create a PorterDuffColorFilter
. A color filter modifies the color of each pixel of a visual resource.
ColorFilter filter = new PorterDuffColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN);
The above filter will tint the non-transparent pixels to blue color.
The color filter can be applied to a Drawable
:
drawable.setColorFilter(filter);
It can be applied to an ImageView
:
imageView.setColorFilter(filter);
Also, it can be applied to a Paint
, so that the color that is drawn using that paint, is modified by the filter:
paint.setColorFilter(filter);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents