旋转动画RotateAnimation

旋转动画可以演示一个视图角度改变的动画效果。它的主要属性有:

fromDegrees动画起始时的角度

toDegrees动画终止时的角度

pivotX旋转围绕点的X轴上相对位置,50%代表自己的中点

pivotY旋转围绕点的Y轴上相对位置,50%代表自己的中点


XML

public void onClickJAVA(View v){
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.rotate);
    view.clearAnimation();
    view.startAnimation(animation);
}

JAVA
public void btnClickXML(View v){
    Animation animation;
    animation = new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    animation.setDuration(2000);
    animation.setRepeatCount(3);
    view.clearAnimation();
    view.startAnimation(animation);
}


原文地址:https://www.cnblogs.com/CCCrunner/p/11782055.html