start Animations Rotate - Android User Interface

Android examples for User Interface:View Animation

Description

start Animations Rotate

Demo Code


//package com.java2s;

import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.RotateAnimation;

public class Main {

    public static void startAnimationsRotate(ViewGroup viewgroup,
            int durationMillis, boolean in, AnimationListener listener) {
        Animation animation = null;/*from w  ww  .ja v  a 2  s .  co  m*/
        if (in) {
            animation = new RotateAnimation(-180, 0,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 1.0f);
        } else {
            animation = new RotateAnimation(0, -180,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 1.0f);
        }
        animation.setFillAfter(true);
        animation.setDuration(durationMillis);
        if (listener != null) {
            animation.setAnimationListener(listener);
        }
        viewgroup.startAnimation(animation);
    }
}

Related Tutorials