Read More
Read now

How to Create Expandable Floating Action Button(FAB) Menu

Save

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.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


4 comments

  • 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

    Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

    Deniel Kerr

    Owner and Founder. Opencart

    Talk to Sales
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home