Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove lag when Rotate Animation repeats on Android?

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!

like image 337
Dimitris Makris Avatar asked Dec 27 '11 19:12

Dimitris Makris


People also ask

How do I turn off animations on Android?

To access the Accessibility features on your Android device open the Settings app . In the Settings app, select Accessibility from the list. Now scroll down to the Display section and select Remove Animations to set the toggle switch to On.

How do I turn off infinite animation on Android?

Use clearAnimation() to stop an animation. There is no loadAnimation() on View .

What are the two different type of view animation?

There are two types of animations that you can do with the view animation framework: Tween animation: Creates an animation by performing a series of transformations on a single image with an Animation. Frame animation: or creates an animation by showing a sequence of images in order with an AnimationDrawable .


1 Answers

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>
like image 57
slund Avatar answered Oct 14 '22 15:10

slund