Android examples for Animation:Rotate Animation
create Slide And Rotate Animation
//package com.java2s; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.RotateAnimation; import android.view.animation.TranslateAnimation; public class Main { public static Animation createSlideAndRotate(boolean slide2Right) { AnimationSet animationSet = new AnimationSet(true); final float fromX = slide2Right ? -1.0f : 1.0f; final float toX = slide2Right ? 0.0f : 0.0f; TranslateAnimation in = new TranslateAnimation( Animation.RELATIVE_TO_SELF, fromX, Animation.RELATIVE_TO_SELF, toX, 0, 0.0f, 0, 0.0f); in.setDuration(300);/*from w ww. ja va 2 s. c o m*/ animationSet.addAnimation(in); animationSet.addAnimation(createFastRotateAnimation()); return animationSet; } public static Animation createFastRotateAnimation() { Animation rotate = new RotateAnimation(-2.0f, 2.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setRepeatMode(Animation.REVERSE); rotate.setRepeatCount(Animation.INFINITE); rotate.setDuration(200); rotate.setInterpolator(new AccelerateDecelerateInterpolator()); return rotate; } }