Material Components for Android


Floating Action Buttons

FloatingActionButton displays the primary action in an application. It is a round icon button that’s elevated above other page content. Floating action buttons come in a default and mini size.

Floating action buttons provide quick-access to important or common actions within an app. They have a variety of uses, including:

Floating action buttons adjust their position and visibility in response to other UI elements on the screen. For example, if a Snackbar appears, the floating action button shifts its position to stay fully visible. Or if a bottom sheet partially covers the floating action button, it may hide itself.

Design & API Documentation


The FloatingActionButton widget provides a complete implementation of Material Design’s floating action button component. Example code of how to include the widget in your layout:


  <!-- Main content -->



Note: If the FloatingActionButton is a descendant of a CoordinatorLayout, you get certain behaviors for free. It will automatically shift so that any displayed Snackbars do not cover it, and will automatially hide when covered by an AppBarLayout or BottomSheetBehavior.

Change the icon in the floating action button with:

Change the size of the widget with:

Your theme’s colorAccent provides the default background color of the widget. Change the background color with:

Change the elevation of the widget with:

Handling Clicks

FloatingActionButton handles clicks in the same way as all views:

FloatingActionButton floatingActionButton =
    (FloatingActionButton) findViewById(;

floatingActionButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        // Handle the click.


Use the show and hide methods to animate the visibility of a FloatingActionButton. The show animation grows the widget and fades it in, while the hide animation shrinks the widget and fades it out.