• RotateAnimation:旋转动画,顾名思义,使用该动画,view能产生旋转效果

    比如QQ音乐播放状态的专辑


  • 看一下xml文件:
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android">    <rotate        android:duration="5000"        android:fillAfter="true"        android:fromDegrees="0"        android:pivotX="50%"        android:pivotY="50%"        android:repeatMode="restart"        android:repeatCount="infinite"        android:toDegrees="360" />set>

属性解释:

android:fromDegrees=”0” //从多少度开始旋转
android:toDegrees=”360” //旋转到多少度结束
android:pivotX=”50%” // 相对x轴起始位置开始执行动画,取值(0-100%)
android:pivotY=”50%” // 相对y轴起始位置开始执行动画,取值(0-100%)
android:repeatMode=”restart” //重复模式为:重复动画
android:repeatCount=”infinite”//重复次数:无限次


  • Java代码调用xml文件:
    /**     * 旋转动画     *     * @param context     * @param view 目标view     */    public static void startRotateAnim(Context context, View view) {        Animation animation = AnimationUtils.loadAnimation(context, R.anim.anim_rotate);        animation.setInterpolator(new LinearInterpolator());        if (view != null)            view.startAnimation(animation);    }
  • 效果如下:

  • 纯Java代码动画:
   public static void animRotate(View view){        RotateAnimation animation = new RotateAnimation(0,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);        animation.setDuration(5000);        animation.setFillAfter(true);        animation.setInterpolator(new LinearInterpolator());        animation.setRepeatMode(Animation.RESTART);        animation.setRepeatCount(Animation.INFINITE);        if (view != null)            view.startAnimation(animation);    }

更多相关文章

  1. Android中手机震动的设置(Vibrator)的步骤(Android学习随笔三)
  2. Android(安卓)开机动画
  3. 转 Android(安卓)Animation学习笔记
  4. android常用控件应用之文本框(TextView)特效
  5. Android中实用小知识
  6. Android(安卓)ListView滑动过程中图片显示重复错位闪烁问题解决
  7. Android(安卓)Animation 动画介绍与详解
  8. Android系统定制之bootanimation.zip的制作
  9. Android中的动画研究(二)

随机推荐

  1. Android系统的开机画面显示过程分析(3)
  2. android 数据库 数据倒序排列
  3. 初学Android,电池电量提示(七十五)
  4. 【ListView】自定义控件:下拉刷新
  5. Android 4.4 SystemUI 的面板quicksettin
  6. Android(安卓)CI - Jenkins
  7. SensorService启动
  8. Android 5.0低版本出现Error inflating c
  9. Android版本更新(Service下载 Notificatio
  10. Android多服务器同时打包多个apk