circle Hide View - Android Animation

Android examples for Animation:Slide Animation

Description

circle Hide View

Demo Code


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

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

public class Main {
    public static final int ANIMATION_DURATION_SHORT = 250;

    @TargetApi(21)/*from w  ww . j  av  a2 s . c  o m*/
    public static void circleHideView(final View view,
            AnimatorListenerAdapter listenerAdapter) {
        circleHideView(view, ANIMATION_DURATION_SHORT, listenerAdapter);
    }

    @TargetApi(21)
    public static void circleHideView(final View view, int duration,
            AnimatorListenerAdapter listenerAdapter) {
        int cx = view.getWidth();
        int cy = view.getHeight() / 2;

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

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

        anim.addListener(listenerAdapter);

        if (duration > 0) {
            anim.setDuration(duration);
        } else {
            anim.setDuration(ANIMATION_DURATION_SHORT);
        }
        anim.start();
    }
}

Related Tutorials