hide Item With Animation - Android Animation

Android examples for Animation:Animation to Hide

Description

hide Item With Animation

Demo Code


import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.os.Build;
import android.view.View;
import android.view.ViewAnimationUtils;

public class Main{
    public static void hideItemWithAnim(final View myView) {

        // 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 initialRadius = myView.getWidth();

        if (Build.VERSION.SDK_INT >= 20) {
            // create the animation (the final radius is zero)
            ValueAnimator anim = ViewAnimationUtils.createCircularReveal(
                    myView, cx, cy, initialRadius, 0);

            // make the view invisible when the animation is done
            anim.addListener(new AnimatorListenerAdapter() {
                @Override/*from w w  w . jav a 2 s  . c om*/
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    myView.setVisibility(View.INVISIBLE);
                }
            });
            anim.start();
        } else {
            myView.setVisibility(View.INVISIBLE);
        }

    }
}

Related Tutorials