【问题标题】:How to make whatsapp type of animation for opening the menu from toolbar(actionbar)如何制作whatsapp类型的动画以从工具栏(操作栏)打开菜单
【发布时间】:2015-07-26 22:39:12
【问题描述】:

说明:

  1. 我最近更新了 whatsapp 并注意到 单击工具栏上的菜单项的动画。如何实现这一目标 效果?
  2. 是否有任何开源项目可以实现这一目标?
  3. 我没有发布任何代码,因为。我不知道他们在做什么 它。

Snapshot-1:点击菜单中的附件按钮之前


Snapshot-2:点击菜单中的附件按钮后


如何实现?

【问题讨论】:

标签: android android-menu whatsapp


【解决方案1】:

似乎他们在 pre-L 设备中“移植”了棒棒糖动画。最简单的方法是使用像Igvalle's Material-Animation 这样的库(参见#4)。它的minSdk是16,但我希望你能把它减少到14或以下。

其他一些库:TransitionsBackportPreLollipopTransitiontransitions-everywhere

如果你制作了这个动画,请告诉我!

【讨论】:

  • 我不得不说我的 github 项目并不是一个真正的库,而是一个如何做这种动画的例子:)
【解决方案2】:

我试了一下,我无法让它与 pre-L 设备兼容,但我认为它看起来很酷。

GitHub看看吧

【讨论】:

  • 不错,但对于低于 lolipop 的版本 .... 它不支持 .... whatsapp 是如何做到这一点的
【解决方案3】:

这是一个网页链接,展示了如何实现它。希望对 http://blog.grafixartist.com/circular-reveal-effect-like-whatsapp-in-android/ 有所帮助。

【讨论】:

  • 谢谢 [+1] ......看起来不错,但对于低于 lolipop 的版本......它不支持......whatsapp 是如何做到的
  • 如何为 minsdk 15 实现这个,请帮助我
  • @Devrath 它确实支持棒棒糖以下的版本。一路回到 Android 2.3
【解决方案4】:

是的,我们现在可以在 2.3+ 上使用圆形显示效果

我们可以通过使用这个Circular Reveal Library来实现这个效果。

添加库依赖

 dependencies {
        compile ('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
            transitive = true;
        }
    }

使用普通的RevealFrameLayout & RevealLinearLayout 不用担心,只有目标会被剪掉:)

<io.codetail.widget.RevealFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Put more views here if you want, it's stock frame layout  -->

    <android.support.v7.widget.CardView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/awesome_card"
        style="@style/CardView"
        app:cardBackgroundColor="@color/material_deep_teal_500"
        app:cardElevation="2dp"
        app:cardPreventCornerOverlap="false"
        app:cardUseCompatPadding="true"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center_horizontal"
        />

</io.codetail.widget.RevealFrameLayout>

并在代码中添加

 View myView = findView(R.id.awesome_card);

    // get the center for the clipping circle
    int cx = (myView.getLeft() + myView.getRight()) / 2;
    int cy = (myView.getTop() + myView.getBottom()) / 2;

    // get the final radius for the clipping circle
    int dx = Math.max(cx, myView.getWidth() - cx);
    int dy = Math.max(cy, myView.getHeight() - cy);
    float finalRadius = (float) Math.hypot(dx, dy);

    SupportAnimator animator =
            ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(1500);
    animator.start();

【讨论】:

  • 外部触摸不像 WhatsApp 那样隐形?
  • ViewAnimationUtils 导入成功,但无法导入 SupportAnimator。我已经添加了 jitpack maven 和 lib 依赖项。
猜你喜欢
  • 2021-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-27
  • 1970-01-01
相关资源
最近更新 更多