Is it possible to tint the drawableLeft in an android button? I have a black drawable I\'d like to tint white. I know how to achieve this with an image view (image on the le
I know there are lots of answers already, but non of them made me happy since I didn't want to have different drawables for different styles of elements.
So my solution was to set color filter in constructor like this:
int textColor = getTextColors().getColorForState(EMPTY_STATE_SET, Color.WHITE);
Drawable[] drawables = getCompoundDrawablesRelative();
for (Drawable drawable : drawables) {
if(drawable != null) {
drawable.setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP);
}
}
I used text color because this was what I need, but it can be replaced with custom attribute to be more dinamic.