Android: how to change dynamically the button icon color? -


i have button in layout:

<button    android:id="@+id/followers_right"    android:drawableleft="@drawable/ic_team"    android:text="@string/visibility_right_followers" /> 

by default, icons grey. in cases, want apply specific color. , drawable button, how can programmatically ?

mybutton.setcolorfilter(getresources().getcolor(r.color.tint_selected)); 

this line doesn't work (build error).

thanks help!

i tried find solution myself interesting question not there yet. 1 work around have same icon in different colors drawable resources,

and change icon of button grammatically,

yourbuttom.setcompounddrawableswithintrinsicbounds(r.drawable.low, 0, 0, 0);  

but issue is, if want huge range of color chages


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -