Morph floating action button into related actions

微笑、不失礼 提交于 2019-12-14 02:47:19

问题


I would like to morph the floating action button into related actions after it is first touched. If one of these buttons gets clicked the corresponding action will be performed and the buttons morph back to the single floating action button. If you touch anywhere else on the screen, no action will be performed and the buttons morph back to the single floating action button.

Lets image the example of a simple editor, that implements an action button to create a new file. Clicking this action button should morph this button into three different buttons, which let me choose one of three file types to create. This behavior is description in Google's material design specification, but I cannot find an example implementation, that helps me getting started.


回答1:


I personally used futuresimple's android-floating-action-button to make 2 java class that handles all that.

It supports the four expand directions:

public static final int EXPAND_UP = 0;
public static final int EXPAND_DOWN = 1;
public static final int EXPAND_LEFT = 2;
public static final int EXPAND_RIGHT = 3;

You can add his library or just copy its few java class. Really minimal code and working great.

Or just look at how he animates things (from FloatingActionMenu.java).



来源:https://stackoverflow.com/questions/28050779/morph-floating-action-button-into-related-actions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!