Android examples for android.view.animation:Rotate Animation
start Upsidedown Animation
import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; public class Main{ public static void startUpsidedownAnimation(View view, boolean clockwise, long durationMillis) { startAnimation(view,// w ww .j a v a2 s . c om getUpsidedownAnimation(clockwise, durationMillis)); } public static RotateAnimation getUpsidedownAnimation(boolean clockwise, long durationMillis) { float fromDegrees, toDegrees; if (clockwise) { fromDegrees = -180; toDegrees = 0; } else { fromDegrees = 0; toDegrees = -180; } RotateAnimation anim = new RotateAnimation(fromDegrees, toDegrees, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(durationMillis); anim.setFillAfter(true); return anim; } public static void startAnimation(View view, Animation anim) { view.clearAnimation(); view.startAnimation(anim); //view.invalidate(); } }