37

I want to programmatically remove (reset) my ImageView Tint color which was already set in XML layout.

John F. Miller
  • 26,518
  • 9
  • 69
  • 120
Md.Tarikul Islam
  • 1,101
  • 1
  • 13
  • 16
  • 5
    try `imageview.setColorFilter(null);` – V-rund Puro-hit Jul 20 '17 at 04:14
  • 19
    This 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 Answers1

54

I think if above things doesn't works, you can try adding the image again to the imageview programatically, while adding it again programatically dont 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()
Uday Ramjiyani
  • 1,357
  • 8
  • 21
  • 6
    `imageView.clearColorFilter()` – Gibolt Oct 30 '19 at 00:55
  • 3
    `imageView.setBackgroundTintList(null)` – Gabby Mar 19 '20 at 09:33
  • 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
  • 7
    `ImageViewCompat.setImageTintList(imageView, null);` works for me. – RRGT19 Oct 17 '20 at 15:36
  • @RRGT19 thanks! using ImageViewCompat is the only way that works for me – konnovdev May 20 '22 at 06:47