将浮动动作按钮变形为相关动作 [英] Morph floating action button into related actions

查看:77
本文介绍了将浮动动作按钮变形为相关动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在第一次触摸浮动按钮后将其变形为相关操作.如果单击了这些按钮之一,则将执行相应的操作,并且这些按钮会变回单个浮动操作按钮.如果您触摸屏幕上的其他任何位置,将不会执行任何操作,并且这些按钮会变回单个浮动操作按钮.

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.

让我们以一个简单的编辑器为例,该编辑器实现了一个操作按钮来创建新文件.单击此操作按钮应将此按钮变形为三个不同的按钮,让我选择要创建的三种文件类型之一.这种行为是Google的材料设计规范中的描述,但是我找不到示例实现,可以帮助我入门.

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.

推荐答案

我个人使用

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

它支持四个展开方向:

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;

您可以添加他的库,也可以只复制它的几个Java类.真正的代码很少,而且效果很好.

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

或者只是看看他是如何对事物进行动画处理的(来自FloatingActionMenu.java).

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

这篇关于将浮动动作按钮变形为相关动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆