Start animation to rotate View - Android android.view.animation

Android examples for android.view.animation:Rotate Animation

Description

Start animation to rotate View

Demo Code

import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.LinearInterpolator;

public class Main {

  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  public static void rotateViewStart(final View view) {

    ViewPropertyAnimator viewPropertyAnimator = view.animate();
    viewPropertyAnimator.setInterpolator(new LinearInterpolator());
    viewPropertyAnimator.rotationBy(0.0f);
    viewPropertyAnimator.rotation(360.0f);
    viewPropertyAnimator.setDuration(720l);
    viewPropertyAnimator.withEndAction(new Runnable() {
      @Override//from  www. ja  v a  2s  .c o m
      public void run() {
        view.setRotation(0.0f);
        rotateViewStart(view);
      }
    });
    viewPropertyAnimator.start();
  }

}

Related Tutorials