rotate view - Android android.view.animation

Android examples for android.view.animation:Rotate Animation

Description

rotate view

Demo Code

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;

public class Main{

    /**/*w  w w.ja v a  2s .c om*/
     * rotate view
     *
     * @param view
     * @param from
     * @param to
     * @param duration
     * @param listener listener animator listener adapter, can be null
     * @return ObjectAnimator
     */
    public static ObjectAnimator rotateX(View view, float from, float to,
            int duration, AnimatorListenerAdapter listener) {
        ObjectAnimator rotate = ObjectAnimator.ofFloat(view, "rotation",
                from, to);
        rotate.setDuration(duration);

        if (listener != null) {
            rotate.addListener(listener);
        }

        rotate.start();

        return rotate;

    }

}

Related Tutorials