load Route RotateAnimation - Android android.animation

Android examples for android.animation:RotateAnimation

Description

load Route RotateAnimation

Demo Code

/*//from w w w .  j  av  a  2 s  .  c  om
 * @Title CldAnimationUtils.java
 * @Copyright Copyright 2010-2015 Careland Software Co,.Ltd All Rights Reserved.
 * @author ChenP
 * @date 2015?9?23? ????10:29:04
 * @version 1.0
 */
//package com.java2s;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

public class Main {
    public static final long TIME = 2000;

    public static RotateAnimation loadRouteAlways(float fromDegrees,
            float toDegrees) {
        return loadRoute(fromDegrees, toDegrees, Animation.INFINITE);
    }

    public static RotateAnimation loadRoute(float fromDegrees,
            float toDegrees, int repeatCount) {
        RotateAnimation gpsLocAni = null;
        gpsLocAni = new RotateAnimation(fromDegrees, toDegrees,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        long time = (long) (toDegrees - fromDegrees) * TIME / 360;
        gpsLocAni.setDuration(time);
        if (repeatCount < 0) {
            gpsLocAni.setRepeatCount(Animation.INFINITE);
        } else {
            gpsLocAni.setRepeatCount(repeatCount);
        }

        // gpsLocAni.setRepeatMode(Animation.RESTART);
        gpsLocAni.setFillAfter(true);
        gpsLocAni.setInterpolator(new LinearInterpolator());// ????
        return gpsLocAni;
    }
}

Related Tutorials