Android 中的动画 RotateAnimation类
2016-03-31 13:26
513 查看
RotateAnimation 旋转动画类
RotateAnimation类是Android系统中的旋转变化动画类,用于控制View对象的旋转动作,该类继承于Animation类。RotateAnimation类中的很多方法都与Animation类一致,该类中最常用的方法便是RotateAnimation构造方法。
RotateAnimation类是Android系统中的旋转变化动画类,用于控制View对象的旋转动作,该类继承于Animation类。RotateAnimation类中的很多方法都与Animation类一致,该类中最常用的方法便是RotateAnimation构造方法。
1. RotateAnimation(float fromDegrees, float toDegrees) fromDegrees:旋转的开始角度 toDegrees:旋转的结束角度 X轴顺时针转动到fromDegrees为旋转的起始点, X轴顺时针转动到toDegrees为旋转的起始点。 默认以View左上角顶点为旋转点
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(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坐标的伸缩值。 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度 。效果一样
//获得图片 ImageView arrowImg = (ImageView)findViewById(R.id.head_arrowImageView); //箭头转动动画 RotateAnimation tipsAnimation = new RotateAnimation(0, -180,RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); tipsAnimation.setInterpolator(new LinearInterpolator()); tipsAnimation.setDuration(200); //动画持续时间 tipsAnimation.setFillAfter(true); //动画结束后保持动画 //开始动画 arrowImg.startAnimation(tipsAnimation);
相关文章推荐
- 本文主要是android中几个图片处理的工具,包括(拼接图片,截屏,将控件转换成图片,drawable转成图片,保存bitmap到指定路径)
- 通过JNI调用android驱动
- java SDK及Android SDK环境配置
- Fragment的使用简单介绍【Android】
- Android_解决android.os.NetworkOnMainThr
- I.MX6 Android i2c-tools porting
- Android Small插件化框架源码分析
- Android Small插件化框架源码分析
- Android下pm 命令详解
- android 代理模式创建Activity
- Android实现下拉刷新上拉加载(PullToRefreshLayout)
- android 数据库创建在本地, 监听数据库变化
- Chronometer android自带的倒计时控件
- Android控件拖动的实现
- 怎样解决Android studio中文乱码问题
- Android-include获取其子标签并且设置事件
- $《第一行代码:Android》读书笔记——第2章 Activity
- Android获取软键盘状态
- Android classes.dex 反编译
- Android-动态加载和静态加载Fragment