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?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -