android - Change Color of AppCompatButton programatically -
support library 22.1 introduced new appcompatbutton should tint aware , new drawablecompat class set tint of drawable.
i thought should easy create colored buttons , change button color programatically.
i create button in code, background drawable of , try tint new drawablecompat class , set button.
appcompatbutton btn = new appcompatbutton(context); drawable tintdr = drawablecompat.wrap(btn.getbackground()); drawablecompat.settint(tintdr, color.blue); btn.setbackground(tintdr);
the result on android 5.x button blue ripple effect gets lost , clicking button looks quite strange. on android < 5.0 button grey.
how can tint button programatically on android versions?