• 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. 安卓文字过长,跑马灯文字滚动效果
  2. Android中保存并设置ListView位置
  3. Android 实现多行文本跑马灯效果
  4. Android viewpager 实现画廊效果 左右可见部分子view
  5. Android 开机动画
  6. android 按钮水波纹效果【背景色】
  7. Android消息处理机制实现同步效果
  8. Android实现网易新闻客户端首页效果

随机推荐

  1. 史上最懒的android开发环境配置教程
  2. Nodejs 或 js 判断手机操作系统 Android(
  3. android broadcast intent
  4. Android(安卓)SDK Installation
  5. android中之断点续传
  6. Android(安卓)Light Sensor与Temperature
  7. Android(安卓)P sensor对某个APP方向做旋
  8. 2011.07.05(2)——— android PopupWindo
  9. android 加密 解密
  10. 运行时报错:Invoke-customs are only supp