如何将FAB转换为弹出菜单? [英] How to transform a FAB into a popup menu?

查看:224
本文介绍了如何将FAB转换为弹出菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据材料设计指南 浮动动作按钮可以转换为包含所有动作的单张材料."

According to the material design guideline "The floating action button can transform into a single sheet of material which contains all the actions".

我想在不使用第三方库的情况下创建以下动画.

I want to create the following animation without using third party libraries.

推荐答案

首先,您需要将该动画切成小块. 在该示例中,我可以推断出3个步骤:

First you need to cut that animation in small parts. In that example i can deduce 3 steps:

  1. 点击事件触发的对FAB的波动影响.
  2. 左侧的翻译适用于FAB.
  3. 该卡片上应用了圆形显示"动画.

因此,您需要创建一个FAB(visible)和一个卡(invisible). FAB位于其初始位置,而卡则位于其最后一个位置.在触发了FAB的涟漪效应(步骤1)并再次在FAB上执行移动事件(步骤2结束)之后,您只需要关闭FAB并在卡上启动Reveal动画(步骤3)即可.

So you need to create a FAB (visible) and a card (invisible). The FAB at it initial position and the card to it final one. After having triggered the ripple effect on the FAB (step 1) and at the end of your move event on FAB again (end of step 2), you just need to dismiss the FAB and start the Reveal animation on the card (step 3).

要启动圆形显示动画,只需调用ViewAnimationUtils.createCircularReveal方法.传递您的卡片视图,X,Y起始坐标,半径,仅此而已!困难肯定是要在每个动画之间找到最佳的持续时间和开始/结束坐标,以使其尽可能平滑.

To launch a circular reveal animation, just call the ViewAnimationUtils.createCircularReveal method. Pass your card view, the X,Y start coordinate, the radius and that's it! The difficulty will definitely be to find the best duration and start/end coordinate between each animations to set it as smooth as possible.

如果需要,您可以在这里查看我的帖子 https://stackoverflow.com/a/41957295/1053880 .我使用了一个圆形的揭示动画来在两个工具栏之间创建一个开关.您代码的某些部分将与我的代码相似(我在末尾也恢复了动画).

If you want, you can look my post here https://stackoverflow.com/a/41957295/1053880. I used a circular reveal animation to create a switch between two toolbars. Some part of your code will be similar to mine (i also reverted my anim at the end).

在GitHub上的示例项目

https://github.com/fbourlieux/android-material-circular_reveal_animation

希望获得帮助!

François

有用的链接:

  • Link1: Circular-Reveal-Animation project on GitHub
  • Link2: Create Circular Reveal Animation And Ripple Effect like Whatsapp
  • Link3: Simple Ripple + Reveal + Elevation tutorial
  • Link4: Scale, Translate, Rotate animation
  • Link5: Ripple animation

这篇关于如何将FAB转换为弹出菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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