Android imageview tint

Viewed 8409

While setting tint for an ImageView in xml, I am getting a warning that shows:-

Must use app:tint instead of android:tint

Why should I use app:tint?

5 Answers

Because there were some issues where android:tint wasn't working for version < 21. app:tint works under version 21. Here is a similar problem. Drawable tinting for api <21

In AppCompatImageView it's fine, you could use android:tint.

It looks like this is a bug of Android Studio to me, as it doesn't take into account your minSdkVersion and also app:tint is not supported well in designer preview. It confuse and slow me repeatedly as I don't remember stuff like this when going back to android development.

Hopefully one day they will improve it to be really useful and account also your minSdkVersion but for now it look like its best to ignore that by going to preferences editor inspection and disable app:tint attribute should be used on completely.

Edit: Also I discovered that app:tint dont works on some android version so I am quite confused now I had to change all mistakenly set app:tint to android:tint

This looks like it's a bug. I have an XML with 3 ImageViews that are the exact same (they're copies of eachother), and I get that error in one of them only. Weirdly enough, clicking on Fix converts that line from android:tint="..." to card_view:tint="...".

Only solution so far was to add tools:ignore="UseAppTint" to silence this warning.

Related