Android examples for User Interface:View Hide Show
hide View with animation and set duration
//package com.java2s; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.SuppressLint; import android.view.View; import android.view.ViewAnimationUtils; public class Main { public static final long PERFECT_MILLS = 618; public static final int MINI_RADIUS = 0; @SuppressLint("NewApi") public static void hide(final View myView, float endRadius, long durationMills) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { myView.setVisibility(View.INVISIBLE); return; }/* w ww . jav a2s .c o m*/ int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; int w = myView.getWidth(); int h = myView.getHeight(); int initialRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, endRadius); anim.setDuration(durationMills); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); myView.setVisibility(View.INVISIBLE); } }); anim.start(); } public static void hide(View myView) { hide(myView, MINI_RADIUS, PERFECT_MILLS); } }