只解释 以下参数
float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue
第一个参数是开始旋转的角度
第二个参数是结束的角度
上面两个参数 自己设置下就知道什么意思
比较难懂的是后面四个参数
其实后面四个参数的作用只是为了确定旋转的中心
RotateAnimation animation=new RotateAnimation(0,180, RotateAnimation.RELATIVE_TO_SELF,0.5f,RotateAnimation.RELATIVE_TO_SELF,1f);以上这一段代码 第三个参数 和第五个参数为
RotateAnimation.RELATIVE_TO_SELF
意思是 第4个参数和第6个参数的相对偏移量是相对于控件本身的
那么上面这段代码的旋转中心就应该是 该控件X轴的一半 Y轴的最底部 如图的红点
如果把第六个参数 也就是 Y轴的偏移改成 0.5f
RotateAnimation animation=new RotateAnimation(0,180, RotateAnimation.RELATIVE_TO_SELF,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f);那么改旋转中心应该就是 X轴的一半 Y轴的一半
如果把 第四个参数和 第六个参数 都改成0.1f
RotateAnimation animation=new RotateAnimation(0,180, RotateAnimation.RELATIVE_TO_SELF,0.1f,RotateAnimation.RELATIVE_TO_SELF,0.1f);那么旋转的中心应该是
自己去实验几次条理会更加清晰 !很简单吧!
还有不懂的可以留言 大家一起学习