animate Reveal Show - Android Animation

Android examples for Animation:Animation to Show

Description

animate Reveal Show

Demo Code


import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;

public class Main{
    public static void animateRevealShow(final Context ctx,
            final View view, final int startRadius,
            @ColorRes final int color, int x, int y,
            final Animator.AnimatorListener listener) {
        float finalRadius = (float) Math.hypot(view.getWidth(),
                view.getHeight());/*from   w  w w . ja va 2  s .  co m*/
        Animator anim = ViewAnimationUtils.createCircularReveal(view, x, y,
                startRadius, finalRadius);
        anim.setDuration(500);
        anim.setStartDelay(80);
        anim.setInterpolator(new FastOutLinearInInterpolator());
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                view.setVisibility(View.VISIBLE);
                view.setBackgroundColor(ContextCompat.getColor(ctx, color));
                if (listener != null) {
                    listener.onAnimationStart(animation);
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (listener != null) {
                    listener.onAnimationEnd(animation);
                }
            }
        });
        anim.start();

    }
}

Related Tutorials