Creating a PorterDuff ColorFilter

suggest change

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents