How to make a floating action button become a menu

Viewed 2268

I am trying to make this from the material design guidelines:

Could you tell me how to morph the fab into the desired view?

2 Answers

You can split the task into two steps

  1. Add a Floating Action Button (FAB)
  2. Add a Menu to the OnClick Handler for the button

Add the FAB to your XML layout. In the onClick method you can inflate a PopMenu, as shown here https://www.tutlane.com/tutorial/android/android-popup-menu-with-examples

PopupMenu popup = new PopupMenu(this, fab);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.your_menu, popup.getMenu());
popup.show();

You still need to add some more code to get the animations. Hope this gets you started

Related