旋转动画速度
我希望我的动画只旋转一圈。每次我调整持续时间时,它都会以相同的速度旋转更长/更慢。我哪里错了?
私有静态最终浮点数 ROTATE_FROM = 0.0f; 私有静态最终浮点数 ROTATE_TO = -10.0f * 360.0f; protected RotateAnimation r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, 动画.RELATIVE_TO_SELF, 0.5f, 动画.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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您正在寻找的是
repeatCount
http://developer.android.com/reference/android/view/animation/Animation.html#setRepeatCount(int)
从文档中:
或者您是说动画会继续旋转您设置的任何
持续时间
? (即,您将其设置为 5000,即使它超过“结束”,它也会旋转 5 秒)。如果将该值设置为小于旋转动画所需的时间会怎样?在这种情况下,可能是您的 LinearInterpolator 正在以恒定的变化率进行动画处理。您可以打印computeDurationHint()的值来查看应用程序是否能够猜测持续时间应该有多长。
PS 您的
ROTATE_FROM
和ROTATE_TO
值是多少?I believe what you are looking for is
repeatCount
http://developer.android.com/reference/android/view/animation/Animation.html#setRepeatCount(int)
From the documentation:
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 ofcomputeDurationHint()
to see if the application is able to guess how long the duration should be.P.S. What are your
ROTATE_FROM
andROTATE_TO
values?问题出在 -10.0f 上!
It was the -10.0f that was the problem!