Android examples for Animation:Fade Animation
fade Out View
//package com.java2s; import android.animation.FloatEvaluator; import android.animation.ValueAnimator; import android.view.View; import static android.animation.ValueAnimator.ofObject; public class Main { public static void fadeOutView(final View view, long duration) { if (view.getVisibility() != View.VISIBLE) { return; }//from ww w .j a va 2 s . c om float fromValue = 1.0f; float toValue = 0.0f; view.setAlpha(fromValue); view.requestLayout(); ValueAnimator valueAnimator = ofObject(new FloatEvaluator(), fromValue, toValue); valueAnimator .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setAlpha((float) animator.getAnimatedValue()); } }); valueAnimator.setDuration(duration); valueAnimator.start(); } }