android animation rotate to specific angle
2016-01-13 22:43
579 查看
其他构造器的旋转也可参考这副图。
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度 。效果一样
http://stackoverflow.com/questions/8981845/android-rotate-image-in-imageview-by-an-angle http://developer.android.com/reference/android/view/animation/RotateAnimation.html
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度 。效果一样
http://stackoverflow.com/questions/8981845/android-rotate-image-in-imageview-by-an-angle http://developer.android.com/reference/android/view/animation/RotateAnimation.html
private ImageView myimage;
myimage = (ImageView) findViewById(R.id.image);
private void rotateArraw(float newRotation) { newRotation = newRotation % 360; //创建rotate旋转动画 Animation rotateAnimation = new RotateAnimation(currentRotation, newRotation, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //currentRotation = (currentRotation + 30) % 360; //设置动画持续时间 //rotateAnimation.setInterpolator(new LinearInterpolator()); rotateAnimation.setDuration(0000); rotateAnimation.setFillEnabled(true); rotateAnimation.setFillAfter(true); //开始动画 myimage.startAnimation(rotateAnimation); currentRotation = newRotation; }
相关文章推荐
- android studio获取sha1的值mac版
- ScrollView中嵌套ListView/ExpandableListView显示问题
- Android Binder机制学习计划
- Android--listView的divider分割线样式和边距
- Android Studio 中使用Java 8 特性
- android星星评分自定义控件
- android 初始开发小问题
- android利用xmpp进行即时通信
- Android中怎么用this
- 我的Android进阶之旅------>Android Activity的singleTask加载模式和onActivityResult方法之间的冲突
- Android应用开发中模拟按HOME键效果
- 一些Android大牛的博客链接收集
- android学习项目
- 浅谈Android控件中的ListView优化
- Android客户端与服务器通信方式浅谈
- Android 选择时间,并排序
- Android性能优化典范(四)
- Android自学的感受
- Android 编程之第三方开发 MaoZhuaWeiBo微博开发演示样例-1
- 两分钟彻底让你明白Android Activity生命周期(图文)!