Change color of Floating Action Button from Appcompat 22.2.0 programmatically

user2410644 picture user2410644 · Jun 21, 2015 · Viewed 51.3k times · Source

I would like to know how to change the Floating Action Button color from the Support library 22.2.0 ? I've tried

button.setBackgroundColor(color);

but clearly, this changes the drawable of the button and it turns to a square.

Now I wonder how to change the color but just the color, without touching the shape?

Thanks in advance

Answer

Zuko picture Zuko · Apr 14, 2016

Maybe late but could help.

 fab.setBackgroundTintList(ColorStateList.valueOf(Color
                    .parseColor("#33691E")));

and parse the actual color code from a list of colors You can find here