Updated on
with 948 views

一、xml 中设置动画的变化速率
1.设置动画为加速动画(动画播放中越来越快):
android:interpolator="@android:anim/accelerate_interpolator"
2.设置动画为减速动画(动画播放中越来越慢) :
android:interpolator="@android:anim/decelerate_interpolator"
3.设置动画为先加速在减速(开始速度最快 逐渐减慢):
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
4.先反向执行一段,然后再加速反向回来(相当于我们弹簧,先反向压缩一小段,然后在加速弹出):
android:interpolator="@android:anim/anticipate_interpolator"
5.同上先反向一段,然后加速反向回来,执行完毕自带回弹效果(更形象的弹簧效果):
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
6.执行完毕之后会回弹跳跃几段(相当于我们高空掉下一颗皮球,到地面是会跳动几下):
android:interpolator="@android:anim/bounce_interpolator"
7.循环,动画循环一定次数,值的改变为一正弦函数:Math.sin(2* mCycles* Math.PI* input):
android:interpolator="@android:anim/cycle_interpolator"
8.线性均匀改变:
android:interpolator="@android:anim/linear_interpolator"
9.加速执行,结束之后回弹:
android:interpolator="@android:anim/overshoot_interpolator"
二、代码中设置动画的变化速率
1.设置动画为加速动画(动画播放中越来越快):
animation.setInterpolator(new AccelerateInterpolator());
2.设置动画为减速动画(动画播放中越来越慢) :
animation.setInterpolator(new DecelerateInterpolator());
3.设置动画为先加速在减速(开始速度最快 逐渐减慢):
animation.setInterpolator(new AccelerateDecelerateInterpolator());
4.先反向执行一段,然后再加速反向回来(相当于我们弹簧,先反向压缩一小段,然后在加速弹出):
animation.setInterpolator(new AnticipateInterpolator());
5.同上先反向一段,然后加速反向回来,执行完毕自带回弹效果(更形象的弹簧效果):
animation.setInterpolator(new AnticipateOvershootInterpolator());
6.执行完毕之后会回弹跳跃几段(相当于我们高空掉下一颗皮球,到地面是会跳动几下):
animation.setInterpolator(new BounceInterpolator());
7.循环,动画循环一定次数,值的改变为一正弦函数:Math.sin(2* mCycles* Math.PI* input):
animation.setInterpolator(new CycleInterpolator(2));
8.线性均匀改变:
animation.setInterpolator(new LinearInterpolator());
9.加速执行,结束之后回弹:
animation.setInterpolator(new OvershootInterpolator());