Redeem Now
Read More
Read now

How to Create Expandable Floating Action Button(FAB) Menu


A Floating Action Button(fab) 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.

Sometime we need to create expandable floating Button. On click of floating button some other floating button should be open .

For your reference i have added some code –

first we need to define all FAB at same place so they overlap each other, remember on top the FAB should be that you want to click and to show other. eg:

Now in the java class just define all your FAB and perform the click like shown below:

Now use the animation().translationY() to animate your FAB,I prefer you to use the attribute of this method in DP since only using an int will effect the display compatibility with higher resolution or lower resolution. as shown below:

Now define the above mentioned dimension inside res->values->dimens.xml as shown below:

FAB Example

NOTE : fab1, fab2, fab3 buttons in the illustration above are declared as Global variables so that these can be used in other functions as well.

. . .

Comments (4)

Add Your Comment

  • Katharina S.
    Awesome! thank you 🙂
  • Ayhan
    How do you make the titles appear next to buttons? (FabTitle1, 2, 3)
  • Ayhan
    How do you make the titles (FabTitle1,2,3) appear next to buttons?
    • Pavel
      It makes using LinearLayout (TextView and FAB within it). One menu item – one LinearLayout.
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again