create Circular Show Animator - Android android.animation

Android examples for android.animation:Animator

Description

create Circular Show Animator

Demo Code


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

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

public class Main {
    public static Animator createCircularShowAnimator(final View view) {
        if (view.getVisibility() == View.VISIBLE
                || view.getWindowToken() == null)
            return null;
        // get the center for the clipping circle
        int cx = (view.getLeft() + view.getRight()) / 2;
        int cy = (view.getTop() + view.getBottom()) / 2;

        // get the final radius for the clipping circle
        int finalRadius = view.getWidth();

        // create and start the animator for this view
        // (the start radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, cx,
                cy, 0, finalRadius);//  w  w w  . j  av a 2  s  . c om
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                view.setVisibility(View.VISIBLE);
            }
        });
        return anim;
    }
}

Related Tutorials