Android笔记(13)图片匀速旋转效果
2017-07-17 18:00
369 查看
当我们更新的时候,需要把更新小图标旋转起来,不废话,先爆照
1.写动画的配置文件 version_image_rotate.xml(更多属性见文章尾)
2.写需要选择的图片布局
3.用代码实现开始旋转和停止旋转
附:更多属性意义如下:
android:fromDegrees 起始的角度度数
android:toDegrees 结束的角度度数,负数表示逆时针,正数表示顺时针。如10圈则比android:fromDegrees大3600即可
android:pivotX 旋转中心的X坐标
浮点数或是百分比。浮点数表示相对于Object的左边缘,如5; 百分比表示相对于Object的左边缘,如5%; 另一种百分比表示相对于父容器的左边缘,如5%p; 一般设置为50%表示在Object中心
android:pivotY 旋转中心的Y坐标
浮点数或是百分比。浮点数表示相对于Object的上边缘,如5; 百分比表示相对于Object的上边缘,如5%; 另一种百分比表示相对于父容器的上边缘,如5%p; 一般设置为50%表示在Object中心
android:duration 表示从android:fromDegrees转动到android:toDegrees所花费的时间,单位为毫秒。可以用来计算速度。
android:interpolator表示变化率,但不是运行速度。一个插补属性,可以将动画效果设置为加速,减速,反复,反弹等。默认为开始和结束慢中间快,
android:startOffset 在调用start函数之后等待开始运行的时间,单位为毫秒,若为10,表示10ms后开始运行
android:repeatCount 重复的次数,默认为0,必须是int,可以为-1表示不停止
android:repeatMode 重复的模式,默认为restart,即重头开始重新运行,可以为reverse即从结束开始向前重新运行。在android:repeatCount大于0或为infinite时生效
android:detachWallpaper 表示是否在壁纸上运行
android:zAdjustment 表示被animated的内容在运行时在z轴上的位置,默认为normal。
normal保持内容当前的z轴顺序
top运行时在最顶层显示
bottom运行时在最底层显示
1.写动画的配置文件 version_image_rotate.xml(更多属性见文章尾)
<?xml version="1.0" encoding="utf-8"?> <!-- android:duration="@android:integer/config_mediumAnimTime" --> <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>
2.写需要选择的图片布局
<ImageView android:id="@+id/update_image" style="@style/mine_icon_left" android:src="@drawable/version_check" />
3.用代码实现开始旋转和停止旋转
private ImageView iv_version_rotate; iv_version_rotate=(ImageView).findViewById(R.id.update_image); /** * 开启动画 */ public void startRotate(){ Animation operatingAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.version_image_rotate); LinearInterpolator lin = new LinearInterpolator(); operatingAnim.setInterpolator(lin); if(operatingAnim!=null){ iv_version_rotate.startAnimation(operatingAnim); } } /** * 关闭动画 */ public void stopRotate(){ iv_version_rotate.clearAnimation(); }
附:更多属性意义如下:
android:fromDegrees 起始的角度度数
android:toDegrees 结束的角度度数,负数表示逆时针,正数表示顺时针。如10圈则比android:fromDegrees大3600即可
android:pivotX 旋转中心的X坐标
浮点数或是百分比。浮点数表示相对于Object的左边缘,如5; 百分比表示相对于Object的左边缘,如5%; 另一种百分比表示相对于父容器的左边缘,如5%p; 一般设置为50%表示在Object中心
android:pivotY 旋转中心的Y坐标
浮点数或是百分比。浮点数表示相对于Object的上边缘,如5; 百分比表示相对于Object的上边缘,如5%; 另一种百分比表示相对于父容器的上边缘,如5%p; 一般设置为50%表示在Object中心
android:duration 表示从android:fromDegrees转动到android:toDegrees所花费的时间,单位为毫秒。可以用来计算速度。
android:interpolator表示变化率,但不是运行速度。一个插补属性,可以将动画效果设置为加速,减速,反复,反弹等。默认为开始和结束慢中间快,
android:startOffset 在调用start函数之后等待开始运行的时间,单位为毫秒,若为10,表示10ms后开始运行
android:repeatCount 重复的次数,默认为0,必须是int,可以为-1表示不停止
android:repeatMode 重复的模式,默认为restart,即重头开始重新运行,可以为reverse即从结束开始向前重新运行。在android:repeatCount大于0或为infinite时生效
android:detachWallpaper 表示是否在壁纸上运行
android:zAdjustment 表示被animated的内容在运行时在z轴上的位置,默认为normal。
normal保持内容当前的z轴顺序
top运行时在最顶层显示
bottom运行时在最底层显示
相关文章推荐
- Android之让图片匀速旋转效果
- Android笔记- 使用XML selector 设置按钮点击效果图片
- Android ExifInterface 学习笔记,图片旋转的操作。
- Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)
- Android 笔记:ImageButton单击切换按钮图片效果的实现(转)
- android 根据uri获取路径及图片压缩、旋转的学习笔记
- Android ExifInterface 学习笔记,图片旋转的操作。
- android 动画rotate实现图片不停旋转的效果
- [转]Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)
- Android使用rotate实现图片旋转效果
- Android Tween动画之RotateAnimation实现图片不停旋转效果实例介绍
- 【android开发笔记】为Button的背景图片添加边框式样式效果
- Android提高篇之自定义dialog实现processDialog“正在加载”效果、使用Animation实现图片旋转
- android 匀速旋转动画效果
- Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)
- android图片处理:让图片一直匀速旋转
- Android中如何使用rotate实现图片不停旋转的效果与动画的停止
- [Android]ScaleViewPager--仿“想去”客户端图片展示效果--中轴旋转ViewPager动画实现
- Android ExifInterface 学习笔记,图片旋转的操作。
- Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)