I want to programmatically remove (reset) my ImageView Tint color which was already set in XML layout.
Asked
Active
Viewed 2.6k times
44
-
5try `imageview.setColorFilter(null);` – V-rund Puro-hit Jul 20 '17 at 04:14
-
21This question is NOT A DUPLICATE of the linked question and does not have an answer there (at the time of writing this comment). – talz Mar 25 '18 at 19:30
-
In older APIs you can use: https://developer.android.com/reference/android/support/v4/widget/ImageViewCompat#setimagetintlist passing null as the tintList – pandre Feb 07 '19 at 16:02
1 Answers
58
I think if above things doesn't works, you can try adding the image again to the imageview programatically, while adding it again programatically don't set tintcolor for it, it will be inflated with the original color
myImgView.setImageResource(R.drawable.yourDrwable);
or I think this should work for you.
imageview.setColorFilter(null)
or
imageView.clearColorFilter()
or
imageView.drawable.setTintList(null)
or
ImageViewCompat.setImageTintList(imageView, null);
updated based on the comments

Lino
- 5,084
- 3
- 21
- 39

Uday Ramjiyani
- 1,407
- 9
- 22
-
6
-
5
-
8`imageView.drawable.setTintList(null)` to clear the tint. [Docs](https://developer.android.com/reference/android/graphics/drawable/Drawable#setTintList(android.content.res.ColorStateList)): `Color state list to use for tinting this drawable, or null to clear the tint This value may be null.` – Fatih Jul 20 '20 at 17:32
-
I had used app:tint= in xml and clearColorFilter and colorFilter = null didn't work. But .drawable.setTintList(null) worked if it was done after the drawable had been set to the ImageView. – Warpzit Sep 03 '20 at 10:52
-
10
-
1@RRGT19 thanks! using ImageViewCompat is the only way that works for me – konnovdev May 20 '22 at 06:47
-
1
-
for me I had to do both clearColorFilter() and drawable.setTintList(null) – Christian C Apr 26 '23 at 08:52
-
ImageViewCompat.setImageTintList(ivImage, null); only last one works for me. – Ahamadullah Saikat Jul 05 '23 at 07:01