Example usage for android.view.animation RotateAnimation setFillBefore

List of usage examples for android.view.animation RotateAnimation setFillBefore

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation setFillBefore.

Prototype

public void setFillBefore(boolean fillBefore) 

Source Link

Document

If fillBefore is true, this animation will apply its transformation before the start time of the animation.

Usage

From source file:Main.java

public static void rotate(final View view, float fromDegrees, float toDegrees, long duration) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0)
            view.setRotation(toDegrees);
        else/*from w  ww  .j  a  v a 2 s  . co m*/
            view.animate().rotation(toDegrees).setDuration(duration).start();
    } else {
        RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        rotate.setDuration(duration);
        rotate.setFillEnabled(true);
        rotate.setFillBefore(true);
        rotate.setFillAfter(true);
        addAnimation(view, rotate);
    }
}