10

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!

Dimitris Makris
  • 5,183
  • 2
  • 34
  • 54

2 Answers2

37

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>
slund
  • 6,367
  • 2
  • 26
  • 19
1

I ended up the increasing the android:toDegrees to above 360 like 3600 according to needs. The rotation is smooth now.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54