Reputation: 2271
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.
Upvotes: 1
Views: 2974
Reputation: 18243
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
).
Upvotes: 1