animation that reveals view in a circular expanding animation - Android Animation

Android examples for Animation:Expand Animation

Description

animation that reveals view in a circular expanding animation

Demo Code


//package com.java2s;
import android.animation.Animator;

import android.view.View;
import android.view.ViewAnimationUtils;

public class Main {
    private static int CENTER_X_INDEX = 0;
    private static int CENTER_Y_INDEX = 1;

    public static void enterReveal(View view) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            Integer[] centerXcenterYradius = getCenterXcenterY(view);
            int cx = centerXcenterYradius[CENTER_X_INDEX];
            int cy = centerXcenterYradius[CENTER_Y_INDEX];
            int finalRadius = Math.max(view.getWidth(), view.getHeight()) / 2;

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

            view.setVisibility(View.VISIBLE);
            anim.start();//from   w w  w .j  a v  a2  s  . c o m
        } else {
            view.setVisibility(View.VISIBLE);
        }

    }

    private static Integer[] getCenterXcenterY(View view) {
        Integer[] result = new Integer[2];

        result[CENTER_X_INDEX] = view.getMeasuredWidth() / 2;
        result[CENTER_Y_INDEX] = view.getMeasuredHeight() / 2;
        return result;
    }
}

Related Tutorials