以 xml的形式定义了动画,但是没有起作用 如下: [html] view plain copy <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500" android:repeatMode="restart" android:repeatCount="-1"> <scale android:fromXScale="1" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.5" android:toYScale="1.5"></scale> </set> 解决方法: 把重复播放的 配置 放在对应的 动画效果节点下 [html] view plain copy <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500"> <scale android:fromXScale="1" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%" android:repeatCount="-1" android:repeatMode="restart" android:toXScale="1.5" android:toYScale="1.5"></scale> </set> 如果 同时在代码中 设置了 动画重复配置,起作用的是 xml形式的动画配置 原因如下: Animation 源码中 [html] view plain copy public Animation(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Animation); ..... setRepeatCount(a.getInt(com.android.internal.R.styleable.Animation_repeatCount, mRepeatCount)); setRepeatMode(a.getInt(com.android.internal.R.styleable.Animation_repeatMode, RESTART)); .... }