Reputation: 1552
I want my animation to only spin for one rotation. Everytime I adjust the duration it just spins at the same speed for longer/slower. Where am I going wrong?
private static final float ROTATE_FROM = 0.0f; private static final float ROTATE_TO = -10.0f * 360.0f; protected RotateAnimation r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); r.setDuration(5000); r.setRepeatCount(0); r.setInterpolator(this, android.R.anim.linear_interpolator); r.setAnimationListener(AndroidVideoPlayer.this); favicon.startAnimation(r);
Upvotes: 2
Views: 5290
Reputation: 10814
I believe what you are looking for is repeatCount
r.setRepeatCount(0)
http://developer.android.com/reference/android/view/animation/Animation.html#setRepeatCount(int)
From the documentation:
Sets how many times the animation should be repeated. If the repeat count is 0, the animation is never repeated. If the repeat count is greater than 0 or INFINITE, the repeat mode will be taken into account. The repeat count is 0 by default.
Or are you saying that the animation continues to rotate for whatever duration
you set? (i.e., you set it for 5000 it rotates for 5 seconds even if it overshoots the "end"). What if you set that value to less than the amount of time it takes to rotate your animation?
In that case it's probably your LinearInterpolator
that's animating for a constant rate of change. You could maybe print the value of computeDurationHint()
to see if the application is able to guess how long the duration should be.
P.S. What are your ROTATE_FROM
and ROTATE_TO
values?
Upvotes: 2