Android的动画分成三种:view动画,帧动画,属性动画,严格上说帧动画也是属于view动画的。
view动画的四种变化对应着Animation的四个子类:TranslateAnimation(平移动画),ScaleAnimation(缩放动画),RotateAnimation(旋转动画),AlphaAnimation(透明度动画)。
帧动画是顺序播放一组预先定义好的图片,类似电影播放。
属性动画可以是对任意属性进行动画,在API11(Android3.0)才有.比较常用的几个动画类有ValueAnimator,ObjectAnimator和Animatorset,其中ObjectAnimator继承自ValueAnimator,AnimatorSet是动画集合,可以定义一组动画。属性动画提供监听器监听动画播放过程,主要有如下两个接口:AnimatorUpdateListener和Animator
public static interface AnimatorListener {
/**
* <p>Notifies the start of the animation.</p>
*
* @param animation The started animation.
*/
void onAnimationStart(Animator animation);
/**
* <p>Notifies the end of the animation. This callback is not invoked
* for animations with repeat count set to INFINITE.</p>
*
* @param animation The animation which reached its end.
*/
void onAnimationEnd(Animator animation);
/**
* <p>Notifies the cancellation of the animation. This callback is not invoked
* for animations with repeat count set to INFINITE.</p>
*
* @param animation The animation which was canceled.
*/
void onAnimationCancel(Animator animation);
/**
* <p>Notifies the repetition of the animation.</p>
*
* @param animation The animation which was repeated.
*/
void onAnimationRepeat(Animator animation);
}
public static interface AnimatorUpdateListener {
/**
* <p>Notifies the occurrence of another frame of the animation.</p>
*
* @param animation The animation which was repeated.
*/
void onAnimationUpdate(ValueAnimator animation);
}