View的成员变量
AccelerateDecelerateInterpolator mInterpolator;
View的构造函数中调用
mInterpolator = new AccelerateDecelerateInterpolator();
【View中使用Interpolator实现先加速后减速动画】public void startAnimate() {
if (mAnimate) {
mAnimationFrame = 1;
mAnimate = false;
for (int i = 0;
i < mDrawList.length;
i++) {
mBackList[i] = mDrawList[i];
mDrawList[i] = 0;
}
mHandler.postDelayed(AnimateRunnable, 100);
}
}
Runnable AnimateRunnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
for (int i = 0;
i < mBackList.length;
i++) {
int score = 0;
float input=(float)mAnimationFrame / ANIMATION_FRAME_COUNT;
float out = mInterpolator.getInterpolation(input);
score = (int) (mBackList[i]*out+0.5);
mDrawList[i] = score;
}
mAnimationFrame++;
invalidate();
if (mAnimationFrame < ANIMATION_FRAME_COUNT) {
postDelayed(this, 200);
}
}
};