How to Change Tint Color for an Image in Android

In this article, we will discuss how to change Tint Color for an Image in Android programmatically as well as in XML. Tint color means when we want to change the color of the image while rendering in ImageView. In XML is very easy to change tint color by just setting up the attribute android:tint="" in the ImageView tag, as shown in the following example.

Set Tint Color in XML

     android:tint="#5089fa" />

Change Tint Color Programmatically in Android

We can change the color of an image programmatically in Android using the following setColorFilter method through the ImageView reference object.


imageView.setColorFilter(getResources().getColor(R.color.YOUR_COLOR)); // Add tint color

To remove tint color again we can pass null as color filter. Like

imageView.setColorFilter(null); // Remove tint color


imageView.setColorFilter(resources.getColor(R.color.YOUR_COLOR)); // Add tint color
imageView.setColorFilter(null); // Remove tint color

That’s it. This how to change tint color for an Image in Android.


Convert Bitmap to File in Android

Please share this post:
Native Mobile Application Developer (Android + IOS) having experience in Java, Swift, Kotlin, Objective C, Unity, C#, C/C++, NODE JS & PHP.

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: