How to set tint for an image view programmatically in android?

Forums AndroidHow to set tint for an image view programmatically in android?
Staff asked 2 years ago

Answers (1)

Add Answer
Vaibhav Donga Marked As Accepted
Staff answered 2 years ago

You can change the tint, quite easily in code via:

imageView.setColorFilter(Color.argb(255, 255, 255, 255)); // White Tint

If you want color tint then

imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.MULTIPLY);

For Vector Drawable

imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.SRC_IN);

This is working for me, Thanks.

Ajay replied 2 years ago

Subscribe

Select Categories