首页 > 移动平台 > 详细

(原)android补间动画(四)之插补器Interpolator

时间:2015-11-02 23:01:07      阅读:706      评论:0      收藏:0      [点我收藏+]

比如说一段旋转动画

RotateAnimation animation = new RotateAnimation(0, 360,
                mMoveCircle.getMeasuredWidth() / 2,
                mMoveCircle.getMeasuredHeight() / 2);
animation.setDuration(1000);
animation.setRepeatCount(3);//共转4圈

这样设定好animation对象后就已经可以用了

mView.startAnimation(animation);

但是会发现旋转过程并非完全匀速

如果我们想要让它完全匀速地旋转,或者加速旋转,或者任何我们想要的速度效果

那么这个时候就可以使用插补器了

例如:

匀速:

LinearInterpolator i = new LinearInterpolator();
animation.setInterpolator(i);

加速:

AccelerateInterpolator i = new AccelerateInterpolator(3);

animation.setInterpolator(i);

遇障反弹:

BounceInterpolator i = new BounceInterpolator();

animation.setInterpolator(i);

以及数个系统自带的效果(它们都是Interpolator接口的子类,可参阅SDK)

如果想要更加客制化的效果,可以写自己的插补器

例如,这里是用一个匿名类来实现的幂函数加速规则

 Interpolator i = new Interpolator() {

 @Override
 public float getInterpolation(float input) {
 // TODO Auto-generated method stub
 // return input*3;//总时长没变,转的圈数增加了
 return input*input;
 }
 };

 

(原)android补间动画(四)之插补器Interpolator

原文:http://www.cnblogs.com/BlogCommunicator/p/4931462.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!