List of usage examples for android.view.animation RotateAnimation reset
public void reset()
From source file:Main.java
public static void shakeAnimation(final View v) { float rotate = 0; int c = mCount++ % 5; if (c == 0) { rotate = DEGREE_0;/*w ww. j ava 2s. co m*/ } else if (c == 1) { rotate = DEGREE_1; } else if (c == 2) { rotate = DEGREE_2; } else if (c == 3) { rotate = DEGREE_3; } else { rotate = DEGREE_4; } final RotateAnimation mra = new RotateAnimation(rotate, -rotate, ICON_WIDTH * mDensity / 2, ICON_HEIGHT * mDensity / 2); final RotateAnimation mrb = new RotateAnimation(-rotate, rotate, ICON_WIDTH * mDensity / 2, ICON_HEIGHT * mDensity / 2); mra.setDuration(ANIMATION_DURATION); mrb.setDuration(ANIMATION_DURATION); mra.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mNeedShake) { mra.reset(); v.startAnimation(mrb); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); mrb.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mNeedShake) { mrb.reset(); v.startAnimation(mra); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); v.startAnimation(mra); }