set Rotate Animation via RotateAnimation - Android android.view.animation

Android examples for android.view.animation:Rotate Animation

Description

set Rotate Animation via RotateAnimation

Demo Code

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

public class Main {

  public static void setRotateAnim(View view) {
    RotateAnimation anim = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
        0.5f);/*  w  w  w  .  j  ava 2  s . c o  m*/
    LinearInterpolator lir = new LinearInterpolator();
    anim.setInterpolator(lir);
    anim.setDuration(2000);
    anim.setRepeatCount(Animation.INFINITE);
    view.setAnimation(anim);
    anim.start();

  }

}

Related Tutorials