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

比如说一段旋转动画

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 = newInterpolator() {

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

return input*input;

}

};

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值