get Upside down Animation - Android android.view.animation

Android examples for android.view.animation:Rotate Animation

Description

get Upside down Animation

Demo Code

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

public class Main{

    public static RotateAnimation getUpsidedownAnimation(boolean clockwise,
            long durationMillis) {
        float fromDegrees, toDegrees;
        if (clockwise) {
            fromDegrees = -180;//from  ww  w  .  j ava2s  . c o m
            toDegrees = 0;
        } else {
            fromDegrees = 0;
            toDegrees = -180;
        }
        RotateAnimation anim = new RotateAnimation(fromDegrees, toDegrees,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f);
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(durationMillis);
        anim.setFillAfter(true);
        return anim;
    }

}

Related Tutorials