i want to add a color filter to the imageview

Shashank Degloorkar picture Shashank Degloorkar · Nov 19, 2011 · Viewed 61.7k times · Source

I'd like to add a ColorFilter to ImageView.

Currently I'm using:

ImageView iv = (ImageView)findViewById(resIdOfImageToFilter);
iv.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);

I've checked Multiple Modes in PotterDuff such as SRC_IN, SRC etc., but I'm not getting any difference in any of the modes... All mode turns the whole ImageView in perfect Red color.

I need to blend RED color in the existing image so that image will look with a REDDISH tinge....

Answer

Shashank Degloorkar picture Shashank Degloorkar · Jan 25, 2013

The right way to do it was using PorterDuff.Mode.LIGHTEN.

So the updated code will be like:

ImageView iv = (ImageView)findViewById(resIdOfImageToFilter);
iv.setColorFilter(Color.RED, PorterDuff.Mode.LIGHTEN);