I have a AppCompatEditText with the property backgroundTint setted to an specific color. I've created a method to change the background tint programmatically and its working in all Android versions since API 17 (4.2 Jelly Bean) to API 25 (7.1.1 Nougat), except API 21 (5.0 Lollipop).
I don't know what I'm doing wrong. Here's my code:
public void changeViewBackgroundColor(Context context, View view, int color) {
int theColor = ContextCompat.getColor(context, color);
if (view instanceof TintableBackgroundView) {
ColorStateList colorStateList = ColorStateList.valueOf(theColor);
ViewCompat.setBackgroundTintList(view, colorStateList);
} else {
view.setBackgroundColor(theColor);
}
view.invalidate();
}