Java tutorial
//package com.java2s; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.ScaleAnimation; public class Main { public static AnimationSet FlipAnimation(int duration, int repeatCount) { AnimationSet flip = new AnimationSet(true); if (duration > 20) //Flip anim { Animation from_middle1_anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); from_middle1_anim.setDuration(duration); from_middle1_anim.setStartOffset(0); from_middle1_anim.setRepeatMode(Animation.REVERSE); from_middle1_anim.setRepeatCount(repeatCount); flip.addAnimation(from_middle1_anim); } else // no anim { Animation noAnim = new AlphaAnimation(1f, 1f); noAnim.setDuration(duration); flip.addAnimation(noAnim); } return flip; } }