android - 为 Pre-Lollipop 设备创建 Circular Reveal

标签 android animation material-design animator

首先,这与 Create circular reveal for pre-Lollipop devices (Android) 不是同一个问题

我正在使用那里提到的库来创建 Circular Reveal,但它似乎对我不起作用。

XML

<io.codetail.widget.RevealFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <FrameLayout
            android:id="@+id/circBack"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#ff4081"
            android:visibility="invisible"
            ></FrameLayout>
</io.codetail.widget.RevealFrameLayout>

Java

                View myView = findViewById(R.id.circBack);


                // 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 finalRadius = Math.max(myView.getWidth(), myView.getHeight());


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

圆形显示不显示。我的意思是代码执行时没有任何反应。

Logcat 显示了这一点

07-01 19:15:47.498  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealRadius>

07-01 19:15:47.498  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealRadius>

07-01 19:15:47.498  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealRadius>

07-01 19:15:47.501  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.ViewAnimationUtils$SimpleAnimationListener>

07-01 19:15:47.501  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.ViewAnimationUtils$SimpleAnimationListener>

07-01 19:15:47.502  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedGingerbread>

07-01 19:15:47.502  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedGingerbread>

07-01 19:15:47.502  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedIceCreamSandwich>

07-01 19:15:47.503  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedIceCreamSandwich>

07-01 19:15:47.503  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedJellyBeanMr2>

07-01 19:15:47.503  27556-27556/com.ledo.ledoapp I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<io.codetail.animation.RevealAnimator$RevealFinishedJellyBeanMr2>

但是,如果将 View 设置为在 XML 文件中可见,则循环显示确实有效,但问题是如果我将 View “circBack”设置为在 XML 中可见,它会显示在应用启动的那一刻,这很正常。

这个问题有什么解决办法吗?

最佳答案

看起来您正在“消失” View 中初始化此动画?

尝试获取 View 的可见性并确保在内部运行它

if (mView.getVisibility() == View.VISIBLE)
{
..
..
  anim.start();
}

代码块。

关于android - 为 Pre-Lollipop 设备创建 Circular Reveal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31159440/

相关文章:

ios - 您如何在移动应用程序中制作这些动画介绍教程/演练/屏幕?

javascript - 为什么我的 jQuery 队列执行一次后就停止工作?

ios - 重置 CALayer 绘图/动画

android - 无法使用 Material Design 添加抽屉导航

android - SelectableItemBackground 没有涟漪效应

angular - 你如何使用谷歌 Material 设计(angular4)重置/规范化你的CSS?

android - 为什么在自定义 View 中创建 EditText 的引用会出现空指针异常

java - java API 中的 ijParcelFileDescriptor 始终为 null

android - 为什么谷歌地图不会显示在 flutter 中?

android - 为什么 StatusBar.translucent 在 expo 应用程序中不起作用