In the new AppCompat library, we can tint the button this way:
here's how to do it in kotlin:
view.background.setTint(ContextCompat.getColor(context, textColor))
I had a similar problem. I wished to colour a complex drawable background for a view based on a color (int) value. I succeeded by using the code:
ColorStateList csl = new ColorStateList(new int[][]{{}}, new int[]{color});
textView.setBackgroundTintList(csl);
Where color is an int value representing the colour required. This represents the simple xml ColorStateList:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:color="color here"/>
</selector>
Hope this helps.
The way I managed to get mine to work was by using CompoundButtonCompat.setButtonTintList(button, colour)
.
To my understanding this works regardless of android version.