circular Show View Animation - Android User Interface

Android examples for User Interface:View Hide Show

Description

circular Show View Animation

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 void circularShow(final View view) {
        Animator anim = createCircularShowAnimator(view);
        if (anim != null)
            anim.start();/*from  w  ww . jav a  2s.c om*/
    }

    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);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                view.setVisibility(View.VISIBLE);
            }
        });
        return anim;
    }
}

Related Tutorials