1、概述

插值器定义如何计算动画中的特定值作为时间的函数。例如,指定动画在整个动画中线性发生,这意味着动画在整个时间内均匀移动,或者指定动画以使用非线性时间,例如,在开始或结束时使用加速或减速动画。

Android中提供的Interpolator主要以下几个:

资源ID 说明
AccelerateDecelerateInterpolator @android:anim/accelerate_decelerate_interpolator 变化率开始和结束缓慢但在中间加速。
AccelerateInterpolator @android:anim/accelerate_interpolator 变化率开始缓慢然后加速。
AnticipateInterpolator @android:anim/anticipate_interpolator 变化开始向后然后向前飞行
AnticipateOvershootInterpolator @android:anim/anticipate_overshoot_interpolator 变化开始向后然后向前飞行并超过目标值,最后返回到最终值。
BaseInterpolator 插值器扩展的抽象类
BounceInterpolator @android:anim/bounce_interpolator 更改在结束时反弹
CycleInterpolator @android:anim/cycle_interpolator 重复动画指定的周期数
DecelerateInterpolator @android:anim/decelerate_interpolator 变化率快速开始然后减速
LinearInterpolator @android:anim/linear_interpolator 变化率是恒定的
OvershootInterpolator @android:anim/overshoot_interpolator 变化向前晃动并超过最后一个值然后返回

2、具体使用

xml使用

android:interpolator="@android:anim/accelerate_decelerate_interpolator"

代码使用

Interpolator interpolator = new AccelerateDecelerateInterpolator();
animation.setInterpolator(interpolator);

3、自定义插值器

要想创建一个属于你自己的插值器类,你必须实现 Interpolator 接口。这个接口只定义了一个方法:

public float getInterpolation(float input)

定义Interpolator,定义一个动画以最快的速度启动,然后减速运动至一半,最后加速运动至结束。

public class TestInterpolator implements Interpolator {

    @Override
public float getInterpolation(float input) {
float x = 2.0f * input - 1.0f;
return 0.5f * (x * x * x + 1.0f);
}
}

自定义插值器是不能在xml使用,直接在代码使用

Interpolator interpolator = new TestInterpolator();
animation.setInterpolator(interpolator);

Android Interpolator(插值器)的更多相关文章

  1. Interpolator(插值器)的种类

    Interpolator(插值器)的种类 Interpolator被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repeat ...

  2. Interpolator 插值器

    简介 Interpolator:撺改者,校对机,分类机,插补器 Interpolator 定义了动画的变化速度,可以实现匀速.正加速.负加速.无规则变加速等,这使得基本的动画得以实现加速.减速等效果. ...

  3. android动画之android:interpolator属性使用

    android动画之android:interpolator使用 Interpolator 被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerat ...

  4. Android -- Interpolator

    Interpolator 被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repeated(重复),bounced(弹跳)等. ...

  5. Android Interpolator解析

    本文部分图片转自:https://blog.csdn.net/lgaojiantong/article/details/39451243 目录 自定义插值器 系统插值器 1. 自定义插值器 要自定义插 ...

  6. <Android 基础(三十一)> ObjectAnimator

    简介 ObjectAnimator,是ValueAnimator的子类,支持利用目标视图的属性来实现动画效果.构造ObjectAnimator的时候,将会提取对应的参数来定义动画对象和对象属性.合适的 ...

  7. 几种常用的Interpolator(插值器)的动画效果

    在实现动画的非线性变化的方法中,常用的一种是为动画添加插值器以改变视图的属性值,从而实现理想的动画效果.Interpolator使用相对简单,下面就只给出一些提供的插值器的默认效果. 在代码中:直接调 ...

  8. Android 动画:你真的会使用插值器与估值器吗?

    目录   目录 1. 插值器(Interpolator) 1.1 简介 定义:一个接口 作用:设置 属性值 从初始值过渡到结束值 的变化规律 如匀速.加速 & 减速 等等 即确定了 动画效果变 ...

  9. android.animation(2) - ValueAnimator的 Interpolator 和 Evaluator

    一.插值器 插值器,也叫加速器:有关插值器的知识,我在<Animation动画详解(二)——Interpolator插值器>中专门讲过,大家可以先看看这篇文章中各个加速器的效果.这里再讲一 ...

随机推荐

  1. [学习笔记]Link-Cut Tree

    我终于理解了 \(LCT\)!!!想不到小蒟蒻有一天理解了!!! 1.[模板]Link Cut Tree 存个板子 #include <bits/stdc++.h> using names ...

  2. 《UNIX环境网络编程》第十四章第14.9小结(bug)

    1.源代码中的<sys/devpoll.h>头文件在我的CentOS7系统下的urs/include/sys/目录下没有找到. 而且我的CentOS7也不存在这个/dev/poll文件. ...

  3. Windows Phone开发手记-WinRT下自定义圆形ItemsControl

    这里的ItemsControl指的是Xaml里的集合控件,包括ListView,GridView等,此篇博客主要参考MSDN Blog的一篇文章,具体出处为:http://blogs.msdn.com ...

  4. 群辉6.1.7安装scrapy框架执行爬虫

    只针对会linux命令,会python的伙伴, 使用环境为: 群辉ds3615xs 6.1.7 python3.5 最近使用scrapy开发了一个小爬虫,因为很穷没有服务器可已部署. 所以打起了我那台 ...

  5. POJ 2864

    #include <iostream> #define MAXN 600 using namespace std; int _m[MAXN][MAXN]; int main() { //f ...

  6. spring + mybatis 存取clob

    存的时候会比较麻烦,需要使用select for update的方式更新数据,如果原来没有这一条数据,还需要先新增,新增的时候需要将clob字段存为oracle.sql.CLOB.empty_lob( ...

  7. vue教程1-06 v-bind属性、class和style

    vue教程1-06 属性.class和style 一.属性 属性: v-bind:src="" width/height/title.... 简写: :src="&quo ...

  8. 常用处理数据用法es6 语法糖总结

    一 循环(数组 ,集合)   1 forEach-----------可以遍历得到vaue和index   const arr = ['red', 'green', 'blue'];arr.forEa ...

  9. (转)Python的web服务器

    1.浏览器请求动态页面过程 2.WSGI Python Web Server Gateway Interface (或简称 WSGI,读作“wizgy”). WSGI允许开发者将选择web框架和web ...

  10. 单点登录--CAS认证--web.xml配置详解

    参考网址: https://blog.csdn.net/zhurhyme/article/details/29349543 https://blog.csdn.net/shzy1988/article ...