如何消除 Android 上旋转动画重复时的延迟?
我在 XML 中构建了一个 RotateAnimation
,使用 AnimationUtils
加载它并将其设置为 ImageView
。我面临的问题是,当图像在一轮之后回到其初始位置时,而不是直接进入下一轮,那里有一个小的超时,就像一个滞后。
有什么解决方案可以消除这个超时吗?
您可以在下面找到动画的 xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:duration="1800"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360"/>
</set>
提前致谢!
I have built a RotateAnimation
in an XML, load it with AnimationUtils
and set it to an ImageView
. The problem I face is that, when the image is back to its initial position after one round, instead of proceeding straight to the next round, there is a small timeout there, like a lag.
Is there any solution to remove this timeout?
Below you may find the xml of the animation:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:duration="1800"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360"/>
</set>
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 Linear_interpolator 放在集合上。
You need to put the linear_interpolator on the set.
我最终根据需要将
android:toDegrees
增加到 360 以上,例如 3600。现在旋转很顺利。I ended up the increasing the
android:toDegrees
to above 360 like 3600 according to needs. The rotation is smooth now.