Java tutorial
//package com.java2s; //License from project: Apache License import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.view.View; public class Main { public static void animFlicker(View view, long duration, int repeatCount) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f); ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.0f); alphaIn.setDuration(duration); alphaIn.setStartDelay(duration); alphaOut.setDuration(duration); alphaOut.setRepeatCount(repeatCount); alphaIn.setRepeatCount(repeatCount); animatorSet.playTogether(alphaOut, alphaIn); animatorSet.start(); } }