AnimationSet: Representsa group of Animations that should be played together. The transformation ofeach individual animation are composed together into a single transform. IfAnimationSet sets any properties that its children also set (for example, durationor fillBefore), the values of AnimationSet override the child values.
在Android 中用于制作混合型动画
AnimationSet.setInterpolator:Sets the acceleration curve for this animation. Defaults to a linearinterpolation.
AnimationSet.setRepeatMode():efineswhat this animation should do when it reaches the end. This setting is appliedonly when the repeat count is either greater than 0 or INFINITE
. Defaultsto RESTART
.
如果AnimationSet中有一些设定,如duration,fillBefore等,它包含的子动作也设定了的话,
子动作中的设定将会给覆盖掉。
旋转动画
<rotate
android:fromDegrees="-2"
android:toDegrees="+2"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="infinite"
android:repeatMode="reverse"
/>
android:pivotX="50%" 表示旋转点相对于整个控件的水平坐标。
android:pivotY="50%" 表示旋转点相对于整个控件的垂直坐标。
android:fromDegrees 表示从相对于竖直位置的偏移值处开始旋转。
android:toDegrees表示旋转到相对于竖直位置的偏移值处。
android:duration表示动画持续的时间
android:repeatCount表示动画重复的次数
android:repeatMode 表示动画重复模式
透明度动画
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.2"
android:duration="2000"
android:repeatMode="reverse"
android:repeatCount="infinite" />
fromAlpha 属性为动画起始时透明度
toAlpha 属性为动画结束时透明度