Reputation: 141
I wonder if there is a way to change the color of my image on the button easily, my simple example is like this,
CircleButton.setImageResource(android.R.drawable.ic_media_play);
I have a play audio icon (white) and want to change the icon color to red, like this
CircleButton.setImageResource(ColorChange(Red, android.R.drawable.ic_media_play));
What seems to be the easiest way for doing ColorChange() ?
Upvotes: 3
Views: 3082
Reputation: 17085
Use ColorFilter
to change the button
image color. Your button should be ImageButton
Set the image resource to the ImageButton
CircleButton.setImageResource(android.R.drawable.ic_media_play);
And, change the image color when required like this
CircleButton.setColorFilter(getResources().getColor(R.color.any_color));
Upvotes: 6