如何消除 Android 上旋转动画重复时的延迟?

发布于 2024-12-22 20:24:17 字数 666 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青柠芒果 2024-12-29 20:24:17

您需要将 Linear_interpolator 放在集合上。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/linear_interpolator">
    <rotate
        android:duration="1800"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="infinite"
        android:toDegrees="360"/>
</set>

You need to put the linear_interpolator on the set.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/linear_interpolator">
    <rotate
        android:duration="1800"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="infinite"
        android:toDegrees="360"/>
</set>
蛮可爱 2024-12-29 20:24:17

我最终根据需要将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文