讲解anroid.view.animation。
Animation
Abstraction for an Animation that can be applied to Views, Surfaces, or other objects. See the
animation package description file
.
public abstract class Animation implements Cloneable {...}
该类是一个抽象类,实现Cloneable,可以clone克隆。它的子类包括AlphaAnimation, AnimationSet, RotateAnimation, ScaleAnimation, TranslateAnimation。
AlphaAnimation
RotateAnimation
ScaleAnimation
TranslateAnimation
AnimationSet
Represents a group of Animations that should be played together。
Constructor to use when building an AnimationSet from code
AnimationSet(boolean shareInterpolator)。
-
Parameters:
-
shareInterpolator
Pass true if all of the animations in this set should use the interpolator associated with this AnimationSet. Pass false if each animation should use its own interpolator.
Interpolator
<span style="font-size:12px;">public interface Interpolator extends TimeInterpolator{...}</span>
被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repeated(重复),bounced(弹跳)等。
AccelerateDecelerateInterpolator
在动画开始与结束的地方速率改变比较慢,在中间的时候加速
AccelerateInterpolator
在动画开始的地方速率改变比较慢,然后开始加速
AnticipateInterpolator
开始的时候向后然后向前甩
AnticipateOvershootInterpolator
开始的时候向后然后向前甩一定值后返回最后的值
BounceInterpolator
动画结束的时候弹起
CycleInterpolator
动画循环播放特定的次数,速率改变沿着正弦曲线
DecelerateInterpolator
在动画开始的地方快然后慢
LinearInterpolator
以常量速率改变
OvershootInterpolator
向前甩一定值后再回到原来位置
Transformation
在绘制Tween动画的时候用的,Tween动画的实质就是ParentView不断的调整childView的Canvas的坐标来实现的,在dispathdraw()中,Animation a = ChildView.getAnimation();Transformation tm = a.getTransformation(); //Transformation 中包含一个矩阵和 alpha 值,矩阵是用来做平移、旋转和缩放动画的,通过tm来设置子控件的canvas。