【问题标题】:How can you do a circular expanding hide on a view? (the opposite of a circular reveal)如何在视图上进行圆形扩展隐藏? (与圆形显示相反)
【发布时间】:2015-11-24 09:58:54
【问题描述】:

我想隐藏一个View,从 x,y 坐标开始并向外展开这个隐藏动画。这可能吗?

本质上,这与圆形展示相反。我很满意这是一个 minSdk 21。

额外细节

我在ActivityA 之上有ActivityB(具有半透明背景)。 AcitivityA 已创建,但用户尚不可见。当您单击右下角的 done 按钮时,我想通过隐藏 ActivityB 来显示 ActivityA(使用展开的圆形隐藏动画,从用户按下 done 的位置开始 按钮。)

【问题讨论】:

    标签: android android-animation android-transitions


    【解决方案1】:

    你的想法正好相反。你说你想隐藏Activity B,但同时你显示Activity A
    这就像看着一个半空的玻璃杯。它是半满半空的。两者都是真的。

    试试这个:
    显示Activity B。点击完成后,显示Activity A(具有透明背景)并开始显示动画。

    但是,如果你坚持隐藏部分,这里是如何做到的。

    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, finalRadius, 0);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(1500);
    animator.start();
    

    不是从 0 开始,而是从 finalRadius 开始。
    我建议为所有活动使用透明背景,以避免 OVERDRAW 出于性能目的。
    对于其他试图在 Pre-Lollipop 设备上实现 Circular Reveal 的用户,这是正确的库 (CircularReveal)。在棒棒糖之前,它使用自己的实现。在棒棒糖及更高版本上,它使用本机实现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-17
      • 1970-01-01
      • 2014-06-27
      • 2016-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多