ozodrukh / CircularReveal

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+
MIT License
2.43k stars 391 forks source link

Reverse Circular Reveal Effect #17

Closed aritraroy closed 9 years ago

aritraroy commented 9 years ago

Is it possible to create the reverse Circular Reveal effect?

ozodrukh commented 9 years ago

Yep,


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 finalRadius = Math.max(myView.getWidth(), myView.getHeight());
    // i just swapped from radius, to radius arguments
    SupportAnimator animator =
            ViewAnimationUtils.createCircularReveal(myView, cx, cy, finalRadius, 0);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(1500);
    animator.start();
aritraroy commented 9 years ago

Thanks a lot for it.

tounaobun commented 9 years ago

It does not work for me.

ozodrukh commented 9 years ago

checkout a latest version, i added reverse animation

aritraroy commented 9 years ago

I am just working with the solution that you gave me and its working just fine.

kai91 commented 9 years ago

@tounaobun

If you're talking about the reverse function, you're supposed to use animator.reverse().start().

reverse() only returns the SupportAnimator and not start the animation itself.

ankitbatra11 commented 8 years ago

It's not working for me either. I am using the latest version and I have tried the animator.reverse.start() too.

codekidX commented 7 years ago

Ok I too had the reverse animator problem. Actually I was setting the view INVISIBLE after anim.start(); which does not wait for animation to end.

Solution:

        anim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mConfigCard.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });