Search code examples
androidmaterial-designfloating-action-button

How can I use ExtendedFloationgActionButton with Action Menus


I want to show an action menu when I Press the ExtendedFloatingActionButton as in the image. My menu has 4 items, but I can't figure out how to easily make the FAb expand to display the actions.

I know ExtendedFloatingActionButton is a child class of MaterialButton, rather than FloatingActionButton, therefore working with it slightly differs from using the normal FAB

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        app:backgroundTint="@color/colorAccent"
        android:contentDescription="Menu"
        android:text="Menu"
        app:iconTint="@color/card_background"
        android:textColor="@color/background_card"
        android:textStyle="bold"
        app:icon="@drawable/ic_menu_black_24dp" />

I want to have a result like this:

Expected Resulty


Solution

  • I have found an easy implementation for a FloatingActionButton, but not for an ExtendedFloatingActionButton.

    FAB transformation | animaiton-samples by android at GitHub