动画的类在AndroidSDK/sources/android-17/android/view/animation文件夹中。。。
如下图:
经过整理,可分为3类:
1. Interpolator部分
Interpolator是基类
Class/Interface | Description |
---|---|
AccelerateDecelerateInterpolator | An interpolator whose rate of change starts and ends slowly but accelerates through the middle. |
AccelerateInterpolator | An interpolator whose rate of change starts out slowly and then accelerates. |
AnticipateInterpolator | An interpolator whose change starts backward then flings forward. |
AnticipateOvershootInterpolator | An interpolator whose change starts backward, flings forward and overshoots the target value, then finally goes back to the final value. |
BounceInterpolator | An interpolator whose change bounces at the end. |
CycleInterpolator | An interpolator whose animation repeats for a specified number of cycles. |
DecelerateInterpolator | An interpolator whose rate of change starts out quickly and and then decelerates. |
LinearInterpolator | An interpolator whose rate of change is constant. |
OvershootInterpolator | An interpolator whose change flings forward and overshoots the last value then comes back. |
TimeInterpolator | An interface that allows you to implement your own interpolator. |
是Interpolator的派生类。这些都被统称为Property Animation。
2. Animation部分
Animation是基类。。。
AlphaAnimation
RotateAnimation
ScaleAnimation
TranslateAnimation为Animation的派生类。这些是Animation部分。
3. 杂项
AnimationSet, AnimationUtils, GridLayoutAnimationController, LayoutAnimationController
这些后续分析。。
//
// Add Time: 2013/6/28
有关自定义动画的部分
上次还没有分析TimeInterpolator,现在来分析一下。
interpolator 的含义为:【计】 校对机, 分类机, 插补器, 内插器, 插入器
上次说到那些Interpolator相关的类都是派生与Interpolator的,
很重要的一点Interpolator的父类为TimeInterpolator。
因此我们新建一个类,其父类为TimeInterpolator就可以自定义动画了。
下面是重载的是模拟BounceInterpolator
的动画实现。。
mObjectAnim.setInterpolator(new TimeInterpolator() {
private float bounce(float t) {
return t * t * 8.0f;
}
@Override
public float getInterpolation(float t) {
// TODO Auto-generated method stub
// _b(t) = t * t * 8
// bs(t) = _b(t) for t < 0.3535
// bs(t) = _b(t - 0.54719) + 0.7 for t < 0.7408
// bs(t) = _b(t - 0.8526) + 0.9 for t < 0.9644
// bs(t) = _b(t - 1.0435) + 0.95 for t <= 1.0
// b(t) = bs(t * 1.1226)
t *= 1.1226f;
if (t < 0.3535f) return bounce(t);
else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.7f;
else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f;
else return bounce(t - 1.0435f) + 0.95f;
}
});
你可以更改算法来实现个性的动画。