2019独角兽企业重金招聘Python工程师标准>>>
一、简介
This class provides a simple timing engine for running animations which calculate animated values and set them on target objects.
There is a single timing pulse that all animations use. It runs in a custom handler to ensure that property changes happen on the UI thread.
By default, ValueAnimator uses non-linear time interpolation, via the AccelerateDecelerateInterpolator
class, which accelerates into and decelerates out of an animation. This behavior can be changed by calling setInterpolator(TimeInterpolator)
.
这个类提供了一个简单的计时引擎,他可以计算移动的步进并将这个值设置到需要移动的目标对象来实现动画。
他有一个简单的时间脉冲,所有动画同时使用,它运行在自定义处理程序以确保性能的变化发生在UI线程。
默认情况下,ValueAnimator采用非线性的时间插值,通过acceleratedecelerateinterpolator类,加速和减速的动画。这种行为可以通过调用setinterpolator改变(timeinterpolator)。
意思大概是,ValueAnimator 定义了一个计时器,可以根据编程者自己定义的一个动画区间以及动画的执行时间来计算具体的动画执行,并完成动画。
二、常用函数
1、public void addUpdateListener (ValueAnimator.AnimatorUpdateListener listener)
通过这个方法添加动画移动过程中,需要实现的一些功能。
2、public static ValueAnimator ofFloat (float... values)
public static ValueAnimator ofInt (int... values)
public static ValueAnimator ofObject (TypeEvaluator evaluator, Object... values)
public static ValueAnimator ofPropertyValuesHolder (PropertyValuesHolder... values)
以上四个方法定义,动画要在什么样数据类型的数据之间进行变化
3、public ValueAnimator setDuration (long duration)
设置动画的时长
4、public void setEvaluator (TypeEvaluator value)
设置动画需要使用的evaluator
5、public void setInterpolator (TimeInterpolator value)
定义动画的速度,加速减速等