Android RotateAnimation详解
2013-12-04 17:20
330 查看
其他构造器的旋转也可参考这副图。
RotateAnimation旋转坐标系为以旋转点为坐标系(0,0)点。x轴为0度,顺时针方向旋转一定的角度。
1.RotateAnimation(fromDegrees, toDegrees) [默认以View左上角顶点为旋转点]。
X轴顺时针转动到fromDegrees为旋转的起始点,
X轴顺时针转动到toDegrees为旋转的起始点。
如fromDegrees=0,toDegrees=90;为左上角顶点为旋转点。0度为起始点,90度为终点。进行旋转,旋转了90度
如fromDegrees=60,toDegrees=90;为左上角顶点为旋转点。60度为起始点,90度为终点。进行旋转,旋转了90-60=30度
2.RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
(pivotX,pivotY)为旋转点。pivotX为距离左侧的偏移量,pivotY为距离顶部的偏移量。即为相对于View左上角(0,0)的坐标点。
如View width=100px,height=100px
RotateAnimation(0,10,100,100);则以右下角顶点为旋转点,从原始位置顺时针旋转10度
RotateAnimation(0,90,50,50);则以View的中心点为旋转点,旋转90度
3.RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue)
pivotXType, pivotXValue, pivotYType, pivotYValue 旋转点类型及其值。
Animation.ABSOLUTE为绝对值 其他为百分比。这个和平移动画的一样,不了解可以去那看
如RotateAnimation(0, 90, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 按中心点旋转90度
效果和2例中的RotateAnimation(0,90,50,50);则以View的中心点为旋转点,旋转90度 。效果一样
new RotateAnimation(0, 180, centerX,centerY);
第一个参数表示动画的起始角度,第二个参数表示动画的结束角度,第三个表示动画的旋转中心x轴,第四个表示动画旋转中心y轴。
rotateAnimation.setDuration(1000 * 20);
表动画持续20s。
rotateAnimation.setFillAfter(true);
ture表示动画结束后停留在动画的最后位置,false表示动画结束后回到初始位置,默认为false。
mView.startAnimation(rotateAnimation);
表示在mView中启动动画。
RotateAnimation旋转坐标系为以旋转点为坐标系(0,0)点。x轴为0度,顺时针方向旋转一定的角度。
1.RotateAnimation(fromDegrees, toDegrees) [默认以View左上角顶点为旋转点]。
X轴顺时针转动到fromDegrees为旋转的起始点,
X轴顺时针转动到toDegrees为旋转的起始点。
如fromDegrees=0,toDegrees=90;为左上角顶点为旋转点。0度为起始点,90度为终点。进行旋转,旋转了90度
如fromDegrees=60,toDegrees=90;为左上角顶点为旋转点。60度为起始点,90度为终点。进行旋转,旋转了90-60=30度
2.RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
(pivotX,pivotY)为旋转点。pivotX为距离左侧的偏移量,pivotY为距离顶部的偏移量。即为相对于View左上角(0,0)的坐标点。
如View width=100px,height=100px
RotateAnimation(0,10,100,100);则以右下角顶点为旋转点,从原始位置顺时针旋转10度
RotateAnimation(0,90,50,50);则以View的中心点为旋转点,旋转90度
3.RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue)
pivotXType, pivotXValue, pivotYType, pivotYValue 旋转点类型及其值。
Animation.ABSOLUTE为绝对值 其他为百分比。这个和平移动画的一样,不了解可以去那看
如RotateAnimation(0, 90, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 按中心点旋转90度
效果和2例中的RotateAnimation(0,90,50,50);则以View的中心点为旋转点,旋转90度 。效果一样
new RotateAnimation(0, 180, centerX,centerY);
第一个参数表示动画的起始角度,第二个参数表示动画的结束角度,第三个表示动画的旋转中心x轴,第四个表示动画旋转中心y轴。
rotateAnimation.setDuration(1000 * 20);
表动画持续20s。
rotateAnimation.setFillAfter(true);
ture表示动画结束后停留在动画的最后位置,false表示动画结束后回到初始位置,默认为false。
mView.startAnimation(rotateAnimation);
表示在mView中启动动画。
相关文章推荐
- android调用平台功能
- 首届 Google 暑期大学生博客分享大赛——2010 Andriod 篇——Android项目总结
- cmd 命令执行android avd 创建,安装apk
- Android问题:生成java错误日志文件包含VM Mutex/Monitor currently owned by a thread: None
- Android 2.2之opencore分析
- Android 使用Intent启动常用的应用与服务(转)
- android的日历制作(网址)
- Android软件开发之获取通讯录联系人信息(二十九)
- Android Bundle类
- Android系统文件夹结构
- Android 视频播放器截屏功能实现讲解
- android编程中的琐碎知识点汇总(3)
- android TabHost 使用
- Android控件组合应用二
- Android平板电脑应用开发的技巧
- android Intent
- Android+Audio+相关类
- 避免Android开发中的ANR
- 做了一个android小应用LEDTorch
- android 虚拟机设置屏幕尺寸(800 * 480的)