Creates a material style circular reveal exit animation similar to the one in Google Play. - Android Animation

Android examples for Animation:Animation to Show

Description

Creates a material style circular reveal exit animation similar to the one in Google Play.

Demo Code


import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.view.View;
import android.view.ViewAnimationUtils;

public class Main {
  /**/*from  www. j a v  a2  s .  c om*/
   * Creates a material style circular reveal exit animation similar to the one in
   * Google Play.
   * 
   * @param view
   *          your view.
   */
  @TargetApi(21)
  public static void circularRevealExit(final View view) {
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;

    float initialRadius = (float) Math.hypot(cx, cy);

    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);

    anim.addListener(new AnimatorListenerAdapter() {
      @Override
      public void onAnimationEnd(Animator animation) {
        super.onAnimationEnd(animation);
        view.setVisibility(View.INVISIBLE);
      }
    });

    anim.start();
  }
}

Related Tutorials