Android 图片旋转动画两种实现方式
2017-08-01 11:12
2911 查看
说明:
让图片旋转两种方法,使用xml和代码xml加载:
xml布局:anim_rotate.xml <?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800" // 设置动画持续时间
android:fromDegrees="0.0" // 设置动画开始时的角度
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50.0%" // 设置动画相对于控件的x坐标的位置
android:pivotY="50.0%" // 设置动画相对于控件的y坐标的位置
android:repeatCount="infinite" // 设置无线循环
android:toDegrees="360.0" /> // 设置动画结束时的旋转角度 开始:
Animation anim = AnimationUtils.loadAnimation(VarietiesSelectActivity.this, R.anim.anim_rotate); anim.setFillAfter(true);//设置旋转后停止 iv_down.startAnimation(anim);结束:iv_down.clearAnimation();
代码实现:
public void rotateAnim() { Animation anim =new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setFillAfter(true); // 设置保持动画最后的状态 anim.setDuration(3000); // 设置动画时间 anim.setInterpolator(new AccelerateInterpolator()); // 设置插入器 anim.setFillAfter(true);// 设置旋转后停止 imageview.startAnimation(anim); }
相关文章推荐
- android实现图片闪烁动画效果的两种实现方式(实用性高)
- android旋转动画的两种实现方式
- android旋转动画的两种实现方式
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转
- android带有文字的图片按钮的两种实现方式
- 如何在Android中实现图片及动画的缩放和旋转
- 2014-11-8Android学习------Android 实现图片的旋转--------动画Animation学习篇
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android实现加载(loading)图片旋转的三种方式
- Android Tween动画之RotateAnimation实现图片360°不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转
- 如何在Android中实现图片及动画的缩放和旋转
- android中动画实现的两种方式
- Android利用Camera实现图片的旋转动画
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转
- Android Tween动画之RotateAnimation实现图片不停旋转