Lightning Round: Android Gradient Floating Action Button

The purpose of this, and other Lighting Round articles, is to share a small, but possibly useful, piece of information/code/concept that could be of some help, and hopefully, even save you some time. You’ll be done before The Flash has a chance to change the timeline!

So everybody loves a FAB, right? And gradients seem to be everywhere nowadays, correct? So it was just a matter of time before someone needed a FAB with a gradient background.

I tried a couple of approaches I read here and there, but honestly, either I couldn’t make them work, or just didn’t like them. Finally, I came across this other way of doing it which I’ll show you here. I was a little skeptical at first, but I was more than satisfied with the end result.

Here’s the code (notice the size is defined via the style, not the layout, just cause).

And here’s what you get:

That’s it. This has worked for me every single time, and I like it. If you know of a better way, please, leave a comment below so we can all benefit from that knowledge :)


Passionate Android developer with tons left to learn.