Android examples for User Interface:View Fade
Fades the specified view out.
//package com.java2s; import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; public class Main { /**/*from w w w . j ava2 s. c o m*/ * Fades the specified view out. * * @param v * the view to fade out */ public static void fadeOut(final View v) { if (v.getVisibility() == View.VISIBLE) { AlphaAnimation fadeOut = new AlphaAnimation(1F, 0F); fadeOut.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.INVISIBLE); } }); fadeOut.setDuration(500); fadeOut.setFillAfter(true); v.startAnimation(fadeOut); } } }