为早期版本的Android设备创建圆形展开效果

5

首先,这并不是与为Lollipop之前的设备创建圆形揭示效果(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文件中将视图设置为可见,则循环揭示确实起作用,但问题是,如果我在XML中将视图“circBack”设置为可见,则它会从应用程序启动时就显示出来,这是通常的情况。有没有解决这个问题的方法?
2个回答

2

可能是Gradle依赖的问题,因为当我以这种方式添加库时它可以工作:

错误的方式

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

正确的方式

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

很抱歉回复晚了,希望能对需要帮助的人有所帮助。


2

看起来你正在对"隐藏"视图进行初始化动画?

尝试获取视图的可见性,并确保在内部运行。

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

代码块。


我将视图设置为“不可见”,而不是“消失”。 - Rahul Chowdhury
是的,我只是举个例子.. 当您在不可见或已隐藏的视图上调用动画时,就会出现这种错误。 - Somesh Kumar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接