1

I am trying to make my own progressdialog, sort of. I'm just using a Dialog which inflates a Layout. In this layout, I have an ImageView, this imageview should rotate just like the original spinner in the ProgressDialog. I applied this animation to it:

RotateAnimation r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    r.setDuration(10000);
    r.setRepeatCount(r.INFINITE);
    icon.startAnimation(r);

The animation last for 10000 ms obviously. The animation start slowly and ends slowly, is it possible that the rotation speed is constant at all time?

Tobias Moe Thorstensen
  • 8,660
  • 13
  • 71
  • 137

2 Answers2

2

You can set a LinearInterpolator to the animation:

r.setInterpolator(new LinearInterpolator());
Henry
  • 41,816
  • 6
  • 58
  • 77
0

A way to increase speed rotation is to set a duration and a number in repeatCount field that apply to you. Doing so, you can control the speed... Just put some big big numbers and add a listener to your animation and when it ends, start it again if dialog is still displayed.

Buda Gavril
  • 20,719
  • 39
  • 122
  • 185
  • I dont want to increase the speed rotation, I found a perfect rotation speed. But when the animation is finished it slows down, and after like 0.5 seconds it start again. I want to close this gap between the animations. – Tobias Moe Thorstensen Jan 15 '13 at 08:29
  • well, that this may mean that you're doing lots of things in UI thread when it stops... – Buda Gavril Jan 15 '13 at 08:33