srinu_stack
srinu_stack

Reputation: 117

Android Animation - Rotate Image Moves Irregularly

when start the animation it moves slow in the beginning and it gets faster as it move. anyone suggest me. here is my code

  Animation rotateAnim;
  rotateAnim = new RotateAnimation(0, 360,
                                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  rotateAnim.setDuration(60*1000);
  rotateAnim.setInterpolator(new AccelerateInterpolator());
  _mClockNeedle.startAnimation(rotateAnim);

Upvotes: 1

Views: 133

Answers (1)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

You are using a AccelerateInterpolator. The behavior you describe is how this class is made, as specified in the API. You may want to use the LinearInterpolator instead, if you want it to move at a constant rate. There are also other subclasses of Interpolator to chose from.

If you wish for the animation to be shorter or longer this is done with the setDuration method, in milliseconds, as you've set it to 1 minute in your example.

Upvotes: 1

Related Questions