47

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

3
  • 5
    try imageview.setColorFilter(null); Commented Jul 20, 2017 at 4:14
  • 22
    This question is NOT A DUPLICATE of the linked question and does not have an answer there (at the time of writing this comment). Commented Mar 25, 2018 at 19:30
  • In older APIs you can use: developer.android.com/reference/android/support/v4/widget/… passing null as the tintList Commented Feb 7, 2019 at 16:02

1 Answer 1

63

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

Sign up to request clarification or add additional context in comments.

9 Comments

imageView.clearColorFilter()
imageView.setBackgroundTintList(null)
imageView.drawable.setTintList(null) to clear the tint. Docs: Color state list to use for tinting this drawable, or null to clear the tint This value may be null.
ImageViewCompat.setImageTintList(imageView, null); works for me.
@RRGT19 thanks! using ImageViewCompat is the only way that works for me
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.