我可以无限旋转我的图像。但我的问题是图像在达到 360° 时会短暂暂停,然后再次开始旋转。即使我应用“线性插值器”,也会发生同样的情况。 我想要做的是图像在开始下一轮时根本不会暂停。所以它必须在任意角度以相同的速度无限旋转。
Here is my - code. Thanks
<?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="1400"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="360"
android:repeatMode="restart"
android:repeatCount="infinite" />
</set>
How I call it on my code
rotate= AnimationUtils.loadAnimation(context, R.anim.loop_rotate)
binding.imgSecondLayout.startAnimation(rotate)
感谢您的帮助! :)
最佳答案
将 animation.setRepeatCount(Animation.INFINITE)
添加到调用动画的 Java 类中。
我的最终代码在这里给出:
Animation animation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.loop_rotate);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(1400);
youractivity.startAnimation(animation);
关于Android动画无限旋转,不停顿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70416855/