android 旋转动画
来源:互联网 发布:煤田自燃 知乎 编辑:程序博客网 时间:2024/05/16 14:51
1.java代码
int pivotType = Animation.RELATIVE_TO_SELF; // 相对于自己
float pivotX = .5f; // 取自身区域在X轴上的中心点float pivotY = .5f; // 取自身区域在Y轴上的中心点
rotateAnimation = new RotateAnimation(firstFromRoate, lastdegreen,
pivotType, pivotX, pivotType, pivotY); // 围绕自身的中心点进行旋转
firstFromRoate=lastdegreen;
rotateAnimation.setDuration(1000);
rotateAnimation.setRepeatCount(0);
rotateAnimation.setFillAfter(true);
iv_zhizhen.startAnimation(rotateAnimation);
2.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="359"
android:duration="500"
android:repeatCount="-1"
android:pivotX="50%"
android:pivotY="50%" />
</set>
含义表示从0到359度开始循环旋转,0-359(若设置成360在停止时会出现停顿现象)度旋转所用时间为500ms,旋转中心距离view的左顶点为50%距离,距离view的上边缘为50%距离,即正中心,具体每个含义见下面的具体属性介绍。
Animation operatingAnim = AnimationUtils.loadAnimation(this, R.anim.tip);
LinearInterpolator lin = new LinearInterpolator(); //匀速效果
operatingAnim.setInterpolator(lin);
setInterpolator表示设置旋转速率。LinearInterpolator为匀速效果,Accelerateinterpolator为加速效果、DecelerateInterpolator为减速效果,具体可见下面android:interpolator的介绍。
if (operatingAnim != null) {
infoOperatingIV.startAnimation(operatingAnim);
}
完成时
infoOperatingIV.clearAnimation();
- Android 动画 - RoateAnimation 旋转动画
- Android动画之旋转动画
- Android 动画旋转效果
- android 旋转动画
- android旋转动画
- Android旋转动画
- Android 旋转动画
- Android旋转刷新动画
- android 旋转动画
- Android 图片旋转 动画
- Android 旋转动画
- android 图片旋转动画
- android 旋转动画
- Android加载动画 旋转动画 、帧动画
- Android 旋转动画,停止和持续旋转
- Android旋转动画不停顿
- android 细节之 旋转动画
- android 围绕中心旋转动画
- 详细介绍 NPOI操作Excel
- sharepreference不能更改默认路径,随着APP卸载删除,不适合调试保存的数据
- Root Pane Containers(一)
- centos6.4合并两个DVD作为本地yun源
- centos6.6安装mongodb3.2失败问题
- android 旋转动画
- 有关Struts2的个人总结:
- 转 Android 系统编译
- 基于svm的中文文本自动分类系统
- LibLinear(SVM包)使用说明之(一)README
- 很不错的GCD线程 使用和介绍
- 社交网络有依赖症的人都有共同的特点
- excel导入数据到mysql数据库
- [LeetCode]038-Count And Say