RotateAnimation类:旋转变化动画类的使用和总结

RotateAnimation类是Android系统中的旋转变化动画类,用于控制View对象的旋转动作,该类继承于Animation类。RotateAnimation类中的很多方法都与Animation类一致,该类中最常用的方法便是RotateAnimation构造方法。

一、
public RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

参数说明
fromDegrees:旋转的开始角度。
toDegrees:旋转的结束角度。
pivotXType:X轴的伸缩模式,可以取值为ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
pivotXValue:X座标的伸缩值。
pivotYType:Y轴的伸缩模式,可以取值为ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
pivotYValue:Y座标的伸缩值。

pivotXType, pivotXValue, pivotYType, pivotYValue  旋转点类型及其值。
Animation.ABSOLUTE为绝对值 其他为百分比。这个和平移动画的一样
如RotateAnimation(0, 90, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 按中心点旋转90度

顺时针方向旋转为正值,逆时针方向旋转为负值


二、
RotateAnimation(fromDegrees, toDegrees) [默认以View左上角顶点为旋转点]。
参数说明
fromDegrees:旋转的开始角度。
toDegrees:旋转的结束角度。

三、
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
参数说明
以(pivotX,pivotY)为旋转点。从fromDegrees旋转到toDegrees。pivotX为距离左侧的偏移量,pivotY为距离顶部的偏移量。即为相对于View左上角(0,0)的座标点。
如View width=100px,height=100pxRotateAnimation(0,10,100,100);则以右下角顶点为旋转点,从原始位置顺时针旋转10度

四、
new RotateAnimation(0, 180, centerX,centerY);
第一个参数表示动画的起始角度,第二个参数表示动画的结束角度,第三个表示动画的旋转中心x轴,第四个表示动画旋转中心y轴。


五、
rotateAnimation.setDuration(1000 * 20);
表动画持续20s。

六、
rotateAnimation.setFillAfter(true);
ture表示动画结束后停留在动画的最后位置,false表示动画结束后回到初始位置,默认为false。

七、
mView.startAnimation(rotateAnimation);

表示在mView中启动动画。


更加详细的Animation资料见:

http://www.cnblogs.com/feisky/archive/2010/01/11/1644482.html

http://blog.csdn.net/zhy_cheng/article/details/7951092

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章