Adding a FloatingActionButton FAB

suggest change

In the material design, a Floating action button represents the primary action in an Activity.

They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point.

Make sure the following dependency is added to your app’s build.gradle file under dependencies:

compile ''

Now add the FloatingActionButton to your layout file:


where the src attribute references the icon that should be used for the floating action.

The result should look something like this (presuming your accent color is Material Pink):

By default, the background color of your FloatingActionButton will be set to your theme’s accent color. Also, note that a FloatingActionButton requires a margin around it to work properly. The recommended margin for the bottom is 16dp for phones and 24dp for tablets.

Here are properties which you can use to customize the FloatingActionButton further (assuming xmlns:app=" is declared as namespace the top of your layout):

You can find more examples about FAB here.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents