AndroidInterpolator属性设置动画速度

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

AndroidInterpolator属性设置动画速度
Android开发中必定会涉及到动画⽅⾯的效果,那么就会遇到⼀个问题,如果控制动画开始速度,与结束速度。

还有其他的⼀些效果我们可以在xml⾥⾯设置属性
android:interpolator="@android:anim/accelerate_interpolator" 设置动画为加速动画(动画播放中越来越快)
android:interpolator="@android:anim/decelerate_interpolator" 设置动画为减速动画(动画播放中越来越慢)
android:interpolator="@android:anim/accelerate_decelerate_interpolator" 设置动画为先加速在减速(开始速度最快逐渐减慢)
android:interpolator="@android:anim/anticipate_interpolator" 先反向执⾏⼀段,然后再加速反向回来(相当于我们弹簧,先反向压缩⼀⼩段,然后在加速弹出)android:interpolator="@android:anim/anticipate_overshoot_interpolator" 同上先反向⼀段,然后加速反向回来,执⾏完毕⾃带回弹效果(更形象的弹簧效果)android:interpolator="@android:anim/bounce_interpolator" 执⾏完毕之后会回弹跳跃⼏段(相当于我们⾼空掉下⼀颗⽪球,到地⾯是会跳动⼏下)
android:interpolator="@android:anim/cycle_interpolator" 循环,动画循环⼀定次数,值的改变为⼀正弦函数:Math.sin(2* mCycles* Math.PI* input) android:interpolator="@android:anim/linear_interpolator" 线性均匀改变
android:interpolator="@android:anim/overshoot_interpolator" 加速执⾏,结束之后回弹
然后我们在代码中也可以设置,顺序效果同上
animation.setInterpolator(new AccelerateInterpolator());
animation.setInterpolator(new DecelerateInterpolator());
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setInterpolator(new AnticipateInterpolator());
animation.setInterpolator(new AnticipateOvershootInterpolator());
animation.setInterpolator(new BounceInterpolator());
animation.setInterpolator(new CycleInterpolator(2));
animation.setInterpolator(new LinearInterpolator());
animation.setInterpolator(new OvershootInterpolator());
动画不设置Interpolator属性即为默认值,匀速
Interpolator属性也可⾃定义。

相关文档
最新文档