我希望我的动画仅旋转一圈。每次我调整持续时间时,它都会以相同的速度旋转更长/更慢。我哪里出错了?
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);
最佳答案
我相信您正在寻找的是repeatCount
r.setRepeatCount(0)
http://developer.android.com/reference/android/view/animation/Animation.html#setRepeatCount(int )
来自文档:
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.
或者您是说动画会继续旋转您设置的任何持续时间
? (即,您将其设置为 5000,即使它超过“结束”,它也会旋转 5 秒)。如果将该值设置为小于旋转动画所需的时间会怎样?
在这种情况下,可能是您的 LinearInterpolator
正在以恒定的变化率进行动画处理。您可以打印 computeDurationHint()
的值来查看应用程序是否能够猜测持续时间应该有多长。
附注您的 ROTATE_FROM
和 ROTATE_TO
值是多少?
关于android - 旋转动画速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7127689/