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....
android:scaleType. Controls how the image should be resized or moved to match the size of this ImageView. android:src. Sets a drawable as the content of this ImageView.
An ImageView that can display, combine and filter images. Added in 2.0. Subclass of ImageView to handle various common filtering operations.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With