extends Animator
类概述
这个类提供了一个用于计算动画值并将其设置为目标对象的动画的简单时序引擎。
有一个单一的定时脉冲,所有动画使用。它运行在一个自定义处理程序中,以确保用户界面线程中的属性发生更改。
默认情况下,ValueAnimator采用非线性时域插值,通过AccelerateDecelerateInterpolator类,加速和减速的动画。这种行为可以通过调用setinterpolator改变(timeinterpolator)。
动画师可以创建代码或资源文件。这里是一个ValueAnimator资源文件的一个实例:
<animator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:valueFrom="1"
android:valueTo="0"
android:valueType="floatType"
android:repeatCount="1"
android:repeatMode="reverse"/>
它也可以结合使用PropertyValuesHolder和帧标签来创建一个多步骤的动画资源。请注意,您可以指定明确的分数值(从0到1)为每个关键帧来确定时,在整个时间,动画应该到达那个值。或者,你可以把分数和关键帧将在总时间平均分配
<animator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:repeatCount="1"
android:repeatMode="reverse">
<propertyValuesHolder>
<keyframe android:fraction="0" android:value="1"/>
<keyframe android:fraction=".2" android:value=".4"/>
<keyframe android:fraction="1" android:value="0"/>
</propertyValuesHolder>
</animator>
Nested Classes
interface | ValueAnimator.AnimatorUpdateListener | Implementors of this interface can add themselves as update listeners to an ValueAnimator instance to receive callbacks on every animation frame, after the current frame's values have been calculated for thatValueAnimator . |
int | INFINITE | This value used used with the setRepeatCount(int) property to repeat the animation indefinitely. 这个值用来与setrepeatcount(int)属性重复动画无限期。 |
int | RESTART | When the animation reaches the end and repeatCount is INFINITE or a positive value, the animation restarts from the beginning. |
int | REVERSE | When the animation reaches the end and repeatCount is INFINITE or a positive value, the animation reverses direction on every iteration. 逆转 |
Public Constructors
Creates a new ValueAnimator object. 创建一个新的ValueAnimator对象。
Public Methods:
void |
addUpdateListener(
ValueAnimator.AnimatorUpdateListener listener)
Adds a listener to the set of listeners that are sent update events through the life of an animation.
|
void |
cancel()
Cancels the animation.取消动画。
|
ValueAnimator |
clone()
Creates and returns a copy of this
Object .创建并返回该对象的副本。
|
void |
end()
Ends the animation.结束动画。
|
float |
getAnimatedFraction()
Returns the current animation fraction, which is the elapsed/interpolated fraction used in the most recent frame update on the animation.
|
Object |
getAnimatedValue()
The most recent value calculated by this
ValueAnimator when there is just one property being animated.
|
Object |
getAnimatedValue(
String propertyName)
The most recent value calculated by this
ValueAnimator for
propertyName .
|
long |
getCurrentPlayTime()
Gets the current position of the animation in time, which is equal to the current time minus the time that the animation started.获取当前播放时间
|
long |
getDuration()
Gets the length of the animation.获取动画长度。
|
static long |
getFrameDelay()
The amount of time, in milliseconds, between each frame of the animation.每一帧的之间的时间
|
TimeInterpolator |
getInterpolator()
Returns the timing interpolator that this ValueAnimator uses.返回定时插补
|
int |
getRepeatCount()
Defines how many times the animation should repeat.获取动画重复的次数
|
int |
getRepeatMode()
Defines what this animation should do when it reaches the end.
|
long |
getStartDelay()
The amount of time, in milliseconds, to delay starting the animation after
start() is called.延迟多少毫米开始
|
PropertyValuesHolder[] |
getValues()
Returns the values that this ValueAnimator animates between.
|
boolean |
isRunning()
Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).
|
boolean |
isStarted()
Returns whether this Animator has been started and not yet ended.
|
static ValueAnimator |
ofArgb(int... values)
Constructs and returns a ValueAnimator that animates between color values.
|
static ValueAnimator |
ofFloat(float... values)
Constructs and returns a ValueAnimator that animates between float values.
|
static ValueAnimator |
ofInt(int... values)
Constructs and returns a ValueAnimator that animates between int values.
|
static ValueAnimator |
ofObject(
TypeEvaluator evaluator,
Object... values)
Constructs and returns a ValueAnimator that animates between Object values.
|
static ValueAnimator |
ofPropertyValuesHolder(
PropertyValuesHolder... values)
Constructs and returns a ValueAnimator that animates between the values specified in the PropertyValuesHolder objects.
|
void |
pause()
Pauses a running animation.
|
void |
removeAllUpdateListeners()
Removes all listeners from the set listening to frame updates for this animation.
|
void |
removeUpdateListener(
ValueAnimator.AnimatorUpdateListener listener)
Removes a listener from the set listening to frame updates for this animation.
|
void |
resume()
Resumes a paused animation, causing the animator to pick up where it left off when it was paused.
|
void |
reverse()
Plays the ValueAnimator in reverse.
|
void |
setCurrentFraction(float fraction)
Sets the position of the animation to the specified fraction.
|
void |
setCurrentPlayTime(long playTime)
Sets the position of the animation to the specified point in time.
|
ValueAnimator |
setDuration(long duration)
Sets the length of the animation.
|
void |
setEvaluator(
TypeEvaluator value)
The type evaluator to be used when calculating the animated values of this animation.
|
void |
setFloatValues(float... values)
Sets float values that will be animated between.
|
static void |
setFrameDelay(long frameDelay)
The amount of time, in milliseconds, between each frame of the animation.
|
void |
setIntValues(int... values)
Sets int values that will be animated between.
|
void |
setInterpolator(
TimeInterpolator value)
The time interpolator used in calculating the elapsed fraction of this animation.
|
void |
setObjectValues(
Object... values)
Sets the values to animate between for this animation.
|
void |
setRepeatCount(int value)
Sets how many times the animation should be repeated.
|
void |
setRepeatMode(int value)
Defines what this animation should do when it reaches the end.
|
void |
setStartDelay(long startDelay)
The amount of time, in milliseconds, to delay starting the animation after
start() is called.
|
void |
setValues(
PropertyValuesHolder... values)
Sets the values, per property, being animated between.
|
void |
start()
Starts this animation.
|
String |
toString()
Returns a string containing a concise, human-readable description of this object.
|
更详细的内容请参考http://blog.csdn.net/guolin_blog/article/details/43536355
http://blog.csdn.net/guolin_blog/article/details/43816093
http://blog.csdn.net/guolin_blog/article/details/44171115