Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android floating action button with custom background

Is it possible to set a custom background to a floating action button? For example, I'd like the fab to have background color with a gradient, and the "plus" icon on top of that. I've only seen simple background color so far. I'd like to keep using the design support library from Google.

like image 789
kuhnp Avatar asked Oct 11 '25 10:10

kuhnp


1 Answers

You set background color to Floating Action Button through this property:

android:backgroundTint= "@color/colorPrimary"

and this does not accept @drawable. Which means you can not apply any drawable so my answer is NO, you cannot apply gradient to fab.

According to Google Buttons: Floating Action Button documentation, Google suggests to avoid such designs.:

enter image description here

like image 137
Shahzeb Avatar answered Oct 13 '25 23:10

Shahzeb