Android examples for android.view.animation:Fade Animation
infinite fade animation
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.view.View; public class Main{ /**//from w w w. j a v a 2s .co m * infinite fade animation * * @param view * @param singleDuration duration of single alpha animation * @return AnimatorSet */ public static AnimatorSet fadingInfinite(View view, long singleDuration) { ObjectAnimator firstFade = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f).setDuration(singleDuration); ObjectAnimator secondFade = ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.0f).setDuration(singleDuration); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { animatorSet.start(); } }); animatorSet.play(firstFade).before(secondFade); animatorSet.start(); return animatorSet; } }