为前棒棒糖设备创建循环显示

时间:2015-07-01 11:00:59

标签: android animation material-design animator

首先,这与Create circular reveal for pre-Lollipop devices (Android)

的问题不同

我正在使用那里提到的图书馆来创建圆形展示,但它似乎对我不起作用。

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>

然而,如果将视图设置为在XML文件中可见,则圆形显示确实有效,但问题是如果我将视图“ circBack ”设置为在XML中可见,它显示为应用程序启动的那一刻,这是正常的。

解决这个问题的方法是什么?

2 个答案:

答案 0 :(得分:2)

看起来你正在“Gone”视图中初始化这个动画?

尝试获取视图的可见性,并确保在

中运行它
Table2

代码块。

答案 1 :(得分:2)

嗯,这可能是Gradle依赖的一个问题,因为当我以这种方式添加库时它会起作用,

错误的方式

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

正确的方式

dependencies {
    compile 'com.github.ozodrukh:CircularReveal:2.0.1'
}

对不起,迟到了。希望它可以帮助有需要的人。