Android动画设置interpolator插值器

我们可以在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"   
//循环,动画循环一定次数,值的改变为一正弦函数:Math.sin(2* mCycles* Math.PI* input)  
android:interpolator="@android:anim/cycle_interpolator" 
//线性均匀改变
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属性也可自定义
转自:https://www.cnblogs.com/onone/articles/6588335.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 【Android 动画】 动画分类补间动画(Tween动画)帧动画(Frame 动画)属性动画(Property ...
    Rtia阅读 6,260评论 1 38
  • 1 背景 不能只分析源码呀,分析的同时也要整理归纳基础知识,刚好有人微博私信让全面说说Android的动画,所以今...
    未聞椛洺阅读 2,758评论 0 10
  • 动画基础概念 动画分类 Android 中动画分为两种,一种是 Tween 动画、还有一种是 Frame 动画。 ...
    Rtia阅读 1,262评论 0 6
  • 一: 传统 View 动画(Tween/Frame) 1.1 Tween 动画 主要有 4 中:缩放、平移、渐变、...
    dfg_fly阅读 758评论 1 2
  • 转载一篇高质量博文,原地址请戳这里转载下来方便今后查看。1 背景不能只分析源码呀,分析的同时也要整理归纳基础知识,...
    Elder阅读 1,954评论 0 24