Show View with Animation - Android Animation

Android examples for Animation:Animation to Show

Description

Show View with Animation

Demo Code


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

import android.os.Build;

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

public class Main {
    public static Animator reveal(View myView) {
        Animator anim = null;// get the center for the clipping circle
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            try {
                myView.setVisibility(View.VISIBLE);
                int cx = myView.getWidth() / 2;
                int cy = myView.getHeight() / 2;

                // get the final radius for the clipping circle
                float finalRadius = (float) Math.hypot(cx, cy);
                anim = ViewAnimationUtils.createCircularReveal(myView, cx,
                        cy, 0, finalRadius);
                anim.start();/*  w  w w.j ava 2  s  . c  o  m*/
            } catch (IllegalStateException e) {
                myView.setVisibility(View.VISIBLE);
            }
        }
        return anim;
    }
}

Related Tutorials