安卓(Android) 怎么开始旋转一次动画(RotateAnimation)

2019年10月15日21:06:36安卓(Android) 怎么开始旋转一次动画(RotateAnimation)已关闭评论 264 1005字阅读3分21秒

1.简介

安卓(Android) 怎么开始旋转一次动画(RotateAnimation)?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */


import android.view.View;

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

public class Main {
    public static void startOnceRotateAnimation(View v, float from,
            float to, long duration, Animation.AnimationListener listener) {
        RotateAnimation animation = new RotateAnimation(from, to,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);

        animation.setDuration(duration);
        animation.setRepeatCount(0);
        animation.setFillAfter(true);

        v.startAnimation(animation);
    }

    public static void startOnceRotateAnimation(View v, float from,
            float to, long duration) {
        RotateAnimation animation = new RotateAnimation(from, to,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);

        animation.setDuration(duration);
        animation.setRepeatCount(0); 
        animation.setFillAfter(true);
        LinearInterpolator lir = new LinearInterpolator();
        animation.setInterpolator(lir);
        v.startAnimation(animation);
    }
}

 
继续阅读
编程十万个怎么办