旋转动画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);
}


posted @ 2017-04-11 20:47  Philtell  阅读(193)  评论(0编辑  收藏  举报