I can rotate my image infinitely. But my problem is that the image pauses shortly when it reaches 360º and then starts rotating again. It happens the same even when I applied "linear_interpolator".
What I want to do is that the image does not pause at all when it starts the next round. So it has to rotate infinitely with same speed at any degree.
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)
Thanks for help! 🙂
2
Answers
This is due to the small delay after the animation completes its duration (1400 ms in ur case). you can remove this delay for smooth animation.
Remove repeatMode attribute and instead add this line :
The animation will be smooth without any delays
Add
animation.setRepeatCount(Animation.INFINITE)
to your java class where animation is called.My final code is given here: