Android examples for Animation:Fade Animation
fade In 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 fadeInView(final View view, long duration) { float fromValue = 0.0f; float toValue = 1.0f; view.setAlpha(fromValue);//from ww w . ja v a 2 s .c om view.setVisibility(View.VISIBLE); 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(); } }