简体   繁体   中英

How to make a floating action button become a menu

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

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

你可以使用这个库来实现 - MaterialSheetLibrary

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM