1 在res下创建anim文件夹

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">  <rotate    android:interpolator="@android:anim/linear_interpolator"    android:duration="1500"    android:fromDegrees="0"    android:pivotX="50%"    android:pivotY="50%"    android:repeatCount="-1"    android:toDegrees="359"    android:visible="true">  rotate>set>android:interpolator:这个属性是用来设置转动速率的。LinearInterpolator为匀速效果,Accelerateinterpolator为加速效果、DecelerateInterpolator为减速效果,android:repeatCount 重复的次数,默认为0,必须是int,可以为-1表示不停止android:duration属性表示从android:fromDegrees转动到android:toDegrees所花费的时间,单位为毫秒。可以用来计算速度。android:startOffset 在调用start函数之后等待开始运行的时间,单位为毫秒,若为10,表示10ms后开始运行android:repeatMode 重复的模式,默认为restart,即重头开始重新运行,可以为reverse即从结束开始向前重新运行。在android:repeatCount大于0或为infinite时生效android:detachWallpaper 表示是否在壁纸上运行android:zAdjustment 表示被animated的内容在运行时在z轴上的位置,默认为normal。normal保持内容当前的z轴顺序top运行时在最顶层显示bottom运行时在最底层显示

2 布局文件

<?xml version="1.0" encoding="utf-8"?><RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="match_parent"  tools:context="com.example.administrator.myapp.MainActivity">  <ImageView    android:id="@+id/img"    android:layout_centerInParent="true"    android:layout_width="100dp"    android:src="@mipmap/ic_launcher"    android:layout_height="100dp"/>RelativeLayout>

3 代码

  Animation rotate = AnimationUtils.loadAnimation(this, R.anim.aaa);    ((ImageView)findViewById(R.id.img)).setAnimation(rotate);    ((ImageView)findViewById(R.id.img)).startAnimation(rotate);

更多相关文章

  1. Android(安卓)Studio 学习笔记
  2. (Android)搭建NDK开发环境 (二)
  3. Android运行机制
  4. Android(安卓)Studio 2.0 Preview发布,附下载地址,支持即时运行和
  5. ANDROID的MANIFEST.XML文件字段解析
  6. Android(安卓)activity属性设置大全
  7. duplicate files during packaging of apk
  8. 【 Android(安卓)】Android(安卓)Runtime Permissions 解决方案(
  9. Android(安卓)SDK 2.2 开发环境搭建

随机推荐

  1. 推荐--《Android深入浅出》
  2. Android系统架构-[Android取经之路]
  3. Android 自定义控件-SnakeLayout (仿galle
  4. Android studio获取证书指纹 (SHA1)的方
  5. Android命名规范,开发规范,注意点整理(一)
  6. Android通知系统源码解析
  7. Android 日历开发教程[三]
  8. Mac修改环境变量路径中带空格的处理
  9. Android 之窗口小部件高级篇--App Widget
  10. 手把手教你搭建 NDK 环境搭建