Change xml label color

Is there a way to set the color for the shortcut? So will the icon color be overwritten with my custom color?

<item android:drawable="@drawable/icon1" //set color to my icon here android:state_pressed="true" /> <item android:drawable="@drawable/icon2" //set color to my icon here /> 
+5
source share
4 answers

You can use this snippet

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="false"> <bitmap android:src="@drawable/signup_checkbox_empty" android:tint="@color/turquoise" /> </item> <item android:state_checked="true"> <bitmap android:src="@drawable/signup_checkbox_full" android:tint="@color/turquoise" /> </item> <item> <bitmap android:src="@drawable/signup_checkbox_empty" android:tint="@color/turquoise" /> </item> </selector> 
+8
source

android L (5.0) has a TINT function that allows you to change the color of a drawable icon . You can check the example here .

For earlier APIs you need to use multiple drawables with selector strategy

+5
source

Try the following:

 android:drawableTint="@color/icon_color" 
+1
source

Use the tint attribute for your image element (or any other that you use to display the image), for example:

 <ImageView android:layout_width="32dp" android:layout_height="32dp" android:src="@drawable/ic_drawable_resource_name" android:tint="@color/color_name"/> 
0
source

All Articles