Most visited

Recently visited

Added in API level 11

ObjectAnimator

public final class ObjectAnimator
extends ValueAnimator

java.lang.Object
   ↳ android.animation.Animator
     ↳ android.animation.ValueAnimator
       ↳ android.animation.ObjectAnimator


这个ValueAnimator子类提供了对目标对象的动画属性的支持。 这个类的构造函数使用参数来定义将被动画的目标对象以及将被动画的属性的名称。 然后在内部确定适当的设置/获取函数,动画将根据需要调用这些函数来动画属性。

动画师可以从代码或资源文件创建,如下所示:

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:valueTo="200"
    android:valueType="floatType"
    android:propertyName="y"
    android:repeatCount="1"
    android:repeatMode="reverse"/>

使用资源文件时,可以使用PropertyValuesHolderKeyframe来创建更复杂的动画。 使用PropertyValuesHolders允许动画师并行地动画多个属性,如下例所示:

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
                android:duration="1000"
                android:repeatCount="1"
                android:repeatMode="reverse">
    <propertyValuesHolder android:propertyName="x" android:valueTo="400"/>
    <propertyValuesHolder android:propertyName="y" android:valueTo="200"/>
</objectAnimator>

使用关键帧允许动画从开始到结束值遵循更复杂的路径。 请注意,您可以为每个关键帧指定显式小数值(从0到1),以确定在整个持续时间内动画何时应达到该值。 或者,您可以关闭分数,关键帧将在总时间内平均分配。 而且,没有值的关键帧将在动画开始时从目标对象派生出它的值,就像动画师只有一个指定的值一样。 另外,可以指定一个可选的插补器。 内插器将应用于内插器设置的关键帧和前一个关键帧之间的间隔。 未提供插补器时,将使用默认的AccelerateDecelerateInterpolator

<propertyValuesHolder android:propertyName="x" >
    <keyframe android:fraction="0" android:value="800" />
    <keyframe android:fraction=".2"
              android:interpolator="@android:anim/accelerate_interpolator"
              android:value="1000" />
    <keyframe android:fraction="1"
              android:interpolator="@android:anim/accelerate_interpolator"
              android:value="400" />
</propertyValuesHolder>
<propertyValuesHolder android:propertyName="y" >
    <keyframe/>
    <keyframe android:fraction=".2"
              android:interpolator="@android:anim/accelerate_interpolator"
              android:value="300"/>
    <keyframe android:interpolator="@android:anim/accelerate_interpolator"
              android:value="1000" />
</propertyValuesHolder>

Developer Guides

有关使用 ObjectAnimator动画 ObjectAnimator更多信息,请参阅 Property Animation开发人员指南。

也可以看看:

Summary

Inherited constants

From class android.animation.ValueAnimator
From class android.animation.Animator

Public constructors

ObjectAnimator()

创建一个新的ObjectAnimator对象。

Public methods

ObjectAnimator clone()

创建并返回此对象的副本。

String getPropertyName()

获取将被动画的属性的名称。

Object getTarget()

目标对象的属性将由此动画制作动画

static ObjectAnimator ofArgb(Object target, String propertyName, int... values)

构造并返回在颜色值之间进行动画处理的ObjectAnimator。

static <T> ObjectAnimator ofArgb(T target, Property<T, Integer> property, int... values)

构造并返回在颜色值之间进行动画处理的ObjectAnimator。

static ObjectAnimator ofFloat(Object target, String xPropertyName, String yPropertyName, Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着 Path沿着坐标进行动画处理。

static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)

构造并返回在浮动值之间动画的ObjectAnimator。

static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty, Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着 Path沿着坐标进行动画处理。

static ObjectAnimator ofFloat(Object target, String propertyName, float... values)

构造并返回在浮动值之间动画的ObjectAnimator。

static <T> ObjectAnimator ofInt(T target, Property<T, Integer> xProperty, Property<T, Integer> yProperty, Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着 Path沿着坐标进行动画处理。

static <T> ObjectAnimator ofInt(T target, Property<T, Integer> property, int... values)

构造并返回在int值之间动画的ObjectAnimator。

static ObjectAnimator ofInt(Object target, String propertyName, int... values)

构造并返回在int值之间动画的ObjectAnimator。

static ObjectAnimator ofInt(Object target, String xPropertyName, String yPropertyName, Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着 Path沿着坐标进行动画处理。

static ObjectAnimator ofMultiFloat(Object target, String propertyName, float[][] values)

构造并返回一个ObjectAnimator,该动画通过多参数设置器的浮动值进行动画处理。

static ObjectAnimator ofMultiFloat(Object target, String propertyName, Path path)

构造并返回一个ObjectAnimator,它使用沿着给定的 Path的多浮点设置器来动画目标。

static <T> ObjectAnimator ofMultiFloat(Object target, String propertyName, TypeConverter<T, float[]> converter, TypeEvaluator<T> evaluator, T... values)

构造并返回一个ObjectAnimator,它为多浮点参数设置器的值提供动画。

static ObjectAnimator ofMultiInt(Object target, String propertyName, int[][] values)

构造并返回一个ObjectAnimator,该ObjectAnimator通过多参数设置器的int值进行动画处理。

static ObjectAnimator ofMultiInt(Object target, String propertyName, Path path)

构造并返回一个ObjectAnimator,该ObjectAnimator使用给定的 Path的多int设置器来动画目标。

static <T> ObjectAnimator ofMultiInt(Object target, String propertyName, TypeConverter<T, int[]> converter, TypeEvaluator<T> evaluator, T... values)

构造并返回一个ObjectAnimator,它为多个int参数设置器的值进行动画处理。

static <T, V> ObjectAnimator ofObject(T target, Property<T, V> property, TypeEvaluator<V> evaluator, V... values)

构造并返回在Object值之间动画的ObjectAnimator。

static ObjectAnimator ofObject(Object target, String propertyName, TypeConverter<PointF, ?> converter, Path path)

构造并返回一个沿着 Path动画化属性的 Path

static <T, V> ObjectAnimator ofObject(T target, Property<T, V> property, TypeConverter<PointF, V> converter, Path path)

构造并返回一个沿着 Path动画化属性的 Path

static <T, V, P> ObjectAnimator ofObject(T target, Property<T, P> property, TypeConverter<V, P> converter, TypeEvaluator<V> evaluator, V... values)

构造并返回在Object值之间动画的ObjectAnimator。

static ObjectAnimator ofObject(Object target, String propertyName, TypeEvaluator evaluator, Object... values)

构造并返回在Object值之间动画的ObjectAnimator。

static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values)

构造并返回在 PropertyValueHolder对象中指定的值集之间进行动画处理的 PropertyValueHolder

void setAutoCancel(boolean cancel)

autoCancel控制是否在启动具有相同目标和属性的任何其他ObjectAnimator时自动取消ObjectAnimator。

ObjectAnimator setDuration(long duration)

设置动画的长度。

void setFloatValues(float... values)

设置将在之间动画的浮动值。

void setIntValues(int... values)

设置将在之间进行动画处理的int值。

void setObjectValues(Object... values)

为此动画设置动画值。

void setProperty(Property property)

设置将被动画的属性。

void setPropertyName(String propertyName)

设置将要动画的属性的名称。

void setTarget(Object target)

设置其属性将由此动画制作动画的目标对象。

void setupEndValues()

此方法告诉对象使用适当的信息来提取动画的结尾值。

void setupStartValues()

该方法告诉对象使用适当的信息来提取动画的起始值。

void start()

开始这个动画。

String toString()

返回对象的字符串表示形式。

Inherited methods

From class android.animation.ValueAnimator
From class android.animation.Animator
From class java.lang.Object

Public constructors

ObjectAnimator

Added in API level 11
ObjectAnimator ()

创建一个新的ObjectAnimator对象。 这个默认的构造函数主要用于内部; 带参数的其他构造函数通常更有用。

Public methods

clone

Added in API level 11
ObjectAnimator clone ()

创建并返回此对象的副本。 “复制”的确切含义可能取决于对象的类别。 一般意图是,对于任何对象x ,表达式:

 x.clone() != x
will be true, and that the expression:
 x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
 x.clone().equals(x)
will be true, this is not an absolute requirement.

按照惯例,返回的对象应该通过调用super.clone获得。 如果一个类和它的所有超类( Object除外)都遵守这个约定,那将是x.clone().getClass() == x.getClass()

按照惯例,这个方法返回的对象应该独立于这个对象(被克隆)。 要实现这种独立性,可能需要在返回super.clone之前修改对象的一个或多个字段。 通常,这意味着复制包含被克隆对象的内部“深层结构”的任何可变对象,并将这些对象的引用替换为对这些副本的引用。 如果一个类只包含原始字段或对不可变对象的引用,那么通常情况下,不需要修改super.clone返回的对象中的任何字段。

Object的方法clone执行特定的克隆操作。 首先,如果该对象的类没有实现接口Cloneable ,则引发CloneNotSupportedException 请注意,所有数组都被视为实现接口Cloneable并且数组类型T[]clone方法的返回类型为T[] ,其中T是任何引用或基本类型。 否则,此方法创建该对象的类的新实例,并使用该对象的相应字段的内容来初始化其所有字段,就像通过赋值一样; 这些字段的内容本身并不克隆。 因此,此方法执行此对象的“浅拷贝”,而不是“深拷贝”操作。

ObjectObject并不实现接口 Cloneable ,所以在类 Object的对象上调用 clone方法将导致在运行时抛出异常。

Returns
ObjectAnimator a clone of this instance.

getPropertyName

Added in API level 11
String getPropertyName ()

获取将被动画的属性的名称。 这个名字将被用来派生一个setter函数来调用设置动画值。 例如,属性名称foo将导致调用目标对象上的函数setFoo() 如果valueFromvalueTo为空,那么getter函数也将被派生并被调用。

如果此动画制作者使用Property对象而不是属性的字符串名称创建,则此方法将返回该Property对象的name 如果此动画设计器是使用一个或多个PropertyValuesHolder对象创建的,则此方法将返回该对象的name (如果只有一个)或所有名称(如果有多个)的逗号分隔列表。

Returns
String

getTarget

Added in API level 11
Object getTarget ()

目标对象的属性将由此动画制作动画

Returns
Object The object being animated

ofArgb

Added in API level 21
ObjectAnimator ofArgb (Object target, 
                String propertyName, 
                int... values)

构造并返回在颜色值之间进行动画处理的ObjectAnimator。 单个值意味着该值是被动画的值,在这种情况下,起始值将从第一次被调用时被动画的属性和目标对象派生出来start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object should have a public method on it called setName(), where name is the value of the propertyName parameter.
propertyName String: The name of the property being animated.
values int: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofArgb

Added in API level 21
ObjectAnimator ofArgb (T target, 
                Property<T, Integer> property, 
                int... values)

构造并返回在颜色值之间进行动画处理的ObjectAnimator。 单个值意味着该值是被动画的值,在这种情况下,起始值将从被动画的属性和第一次调用start()时的目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated.
values int: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofFloat

Added in API level 21
ObjectAnimator ofFloat (Object target, 
                String xPropertyName, 
                String yPropertyName, 
                Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着Path沿着坐标进行动画处理。 Path动画在两个维度上移动,将坐标(x, y)动画在一起以跟随线条。 在此变体中,坐标是设置为分离由xPropertyNameyPropertyName指定的属性的yPropertyName

Parameters
target Object: The object whose properties are to be animated. This object should have public methods on it called setNameX() and setNameY, where nameX and nameY are the value of the xPropertyName and yPropertyName parameters, respectively.
xPropertyName String: The name of the property for the x coordinate being animated.
yPropertyName String: The name of the property for the y coordinate being animated.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofFloat

Added in API level 14
ObjectAnimator ofFloat (T target, 
                Property<T, Float> property, 
                float... values)

构造并返回在浮动值之间动画的ObjectAnimator。 一个值意味着该值是被动画的值,在这种情况下,起始值将从被动画的属性和第一次调用start()时的目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated.
values float: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofFloat

Added in API level 21
ObjectAnimator ofFloat (T target, 
                Property<T, Float> xProperty, 
                Property<T, Float> yProperty, 
                Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着Path沿着坐标进行动画处理。 Path动画在两个维度上移动,将坐标(x, y)动画在一起以跟随该线条。 在此变体中,坐标是设置为分开属性的浮点数, xPropertyyProperty

Parameters
target T: The object whose properties are to be animated.
xProperty Property: The property for the x coordinate being animated.
yProperty Property: The property for the y coordinate being animated.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofFloat

Added in API level 11
ObjectAnimator ofFloat (Object target, 
                String propertyName, 
                float... values)

构造并返回在浮动值之间动画的ObjectAnimator。 一个值意味着该值是被动画的值,在这种情况下,起始值将从被动画的属性以及第一次调用start()时的目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object should have a public method on it called setName(), where name is the value of the propertyName parameter.
propertyName String: The name of the property being animated.
values float: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofInt

Added in API level 21
ObjectAnimator ofInt (T target, 
                Property<T, Integer> xProperty, 
                Property<T, Integer> yProperty, 
                Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着Path沿着坐标进行动画处理。 Path动画在两个维度上移动,将坐标(x, y)动画在一起以遵循该线。 在此变体中,坐标是设置为分开属性的整数, xPropertyyProperty

Parameters
target T: The object whose properties are to be animated.
xProperty Property: The property for the x coordinate being animated.
yProperty Property: The property for the y coordinate being animated.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofInt

Added in API level 14
ObjectAnimator ofInt (T target, 
                Property<T, Integer> property, 
                int... values)

构造并返回在int值之间动画的ObjectAnimator。 单个值意味着该值是被动画的值,在这种情况下,首次调用start()时, start()动画属性和目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated.
values int: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofInt

Added in API level 11
ObjectAnimator ofInt (Object target, 
                String propertyName, 
                int... values)

构造并返回在int值之间动画的ObjectAnimator。 一个值意味着该值是被动画的值,在这种情况下,首次调用start()时, start()动画属性和目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object should have a public method on it called setName(), where name is the value of the propertyName parameter.
propertyName String: The name of the property being animated.
values int: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofInt

Added in API level 21
ObjectAnimator ofInt (Object target, 
                String xPropertyName, 
                String yPropertyName, 
                Path path)

构造并返回一个ObjectAnimator, Path使用两个属性沿着Path沿着坐标进行动画处理。 Path动画在两个维度上移动,将坐标(x, y)动画在一起以遵循该线。 在此变体中,坐标是被设置为由xPropertyNameyPropertyName指定的独立属性的整数。

Parameters
target Object: The object whose properties are to be animated. This object should have public methods on it called setNameX() and setNameY, where nameX and nameY are the value of xPropertyName and yPropertyName parameters, respectively.
xPropertyName String: The name of the property for the x coordinate being animated.
yPropertyName String: The name of the property for the y coordinate being animated.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofMultiFloat

Added in API level 21
ObjectAnimator ofMultiFloat (Object target, 
                String propertyName, 
                float[][] values)

构造并返回一个ObjectAnimator,该动画通过多参数设置器的浮动值进行动画处理。 只支持只接受浮点参数的公共方法。 每个float[]包含一套完整的setter方法参数。 必须提供至少两个float[]值,一个开始和结束。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
values float: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofMultiFloat

Added in API level 21
ObjectAnimator ofMultiFloat (Object target, 
                String propertyName, 
                Path path)

构造并返回一个ObjectAnimator,它使用沿着给定的Path的多浮动设置器来动画目标。 Path动画在两个维度上移动,将坐标(x, y)动画在一起以遵循该线。 在这个变化中,坐标分别是在设置者的第一个和第二个参数中使用的float x和y坐标。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofMultiFloat

Added in API level 21
ObjectAnimator ofMultiFloat (Object target, 
                String propertyName, 
                TypeConverter<T, float[]> converter, 
                TypeEvaluator<T> evaluator, 
                T... values)

构造并返回一个ObjectAnimator,它为多浮点参数设置器的值提供动画。 只支持只接受浮点参数的公共方法。

至少必须提供两个值,一个开始和结束。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
converter TypeConverter: Converts T objects into float parameters for the multi-value setter.
evaluator TypeEvaluator: A TypeEvaluator that will be called on each animation frame to provide the necessary interpolation between the Object values to derive the animated value.
values T: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofMultiInt

Added in API level 21
ObjectAnimator ofMultiInt (Object target, 
                String propertyName, 
                int[][] values)

构造并返回一个ObjectAnimator,该ObjectAnimator通过多参数设置器的int值进行动画处理。 只支持只接受int参数的公共方法。 每个int[]包含一套完整的setter方法参数。 必须提供至少两个int[]值,一个开始和结束。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
values int: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofMultiInt

Added in API level 21
ObjectAnimator ofMultiInt (Object target, 
                String propertyName, 
                Path path)

构造并返回一个ObjectAnimator,该ObjectAnimator使用给定的Path的多int设置器来动画目标。 一个Path动画在两个维度上移动,将坐标(x, y)动画在一起以遵循该线。 在这个变体中,坐标分别是在设置者的第一个和第二个参数中使用的整数x和y坐标。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofMultiInt

Added in API level 21
ObjectAnimator ofMultiInt (Object target, 
                String propertyName, 
                TypeConverter<T, int[]> converter, 
                TypeEvaluator<T> evaluator, 
                T... values)

构造并返回一个ObjectAnimator,它为多个int参数设置器的值进行动画处理。 只支持只接受int参数的公共方法。

至少必须提供两个值,一个开始和结束。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

Parameters
target Object: The object whose property is to be animated. This object may have a public method on it called setName(), where name is the value of the propertyName parameter. propertyName may also be the case-sensitive complete name of the public setter method.
propertyName String: The name of the property being animated or the name of the setter method.
converter TypeConverter: Converts T objects into int parameters for the multi-value setter.
evaluator TypeEvaluator: A TypeEvaluator that will be called on each animation frame to provide the necessary interpolation between the Object values to derive the animated value.
values T: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofObject

Added in API level 14
ObjectAnimator ofObject (T target, 
                Property<T, V> property, 
                TypeEvaluator<V> evaluator, 
                V... values)

构造并返回在Object值之间动画的ObjectAnimator。 一个值意味着该值是被动画的值,在这种情况下,首次调用start()时, start()被动画的属性和目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

注意:这些值存储为对原始对象的引用,这意味着调用此方法后对这些对象的更改将影响动画器上的值。 如果在调用此方法后对象将在外部发生变化,则调用者应该传递这些对象的副本。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated.
evaluator TypeEvaluator: A TypeEvaluator that will be called on each animation frame to provide the necessary interpolation between the Object values to derive the animated value.
values V: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofObject

Added in API level 21
ObjectAnimator ofObject (Object target, 
                String propertyName, 
                TypeConverter<PointF, ?> converter, 
                Path path)

构造并返回一个沿着Path动画属性的Path 一个Path动画在两个维度上移动,将坐标(x, y)动画在一起以遵循该行。 此变体以PointF的坐标为动画,以跟随Path 如果Property关联propertyName使用比其它类型PointFconverter可以用来从改变PointF与相关联的类型Property

Parameters
target Object: The object whose property is to be animated. This object should have a public method on it called setName(), where name is the value of the propertyName parameter.
propertyName String: The name of the property being animated.
converter TypeConverter: Converts a PointF to the type associated with the setter. May be null if conversion is unnecessary.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofObject

Added in API level 21
ObjectAnimator ofObject (T target, 
                Property<T, V> property, 
                TypeConverter<PointF, V> converter, 
                Path path)

构造并返回一个沿着Path动画属性的Path Path动画在两个维度上移动,将坐标(x, y)动画(x, y)一起以遵循该线。 此变体以PointF的坐标为动画,以跟随Path 如果property使用比其它类型PointFconverter可以用来从改变PointF与相关联的类型Property

PointF传递给 converterproperty ,如果 converternull ,则在每个动画帧上重用,并且不应由setter或TypeConverter存储。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated. Should not be null.
converter TypeConverter: Converts a PointF to the type associated with the setter. May be null if conversion is unnecessary.
path Path: The Path to animate values along.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate along path.

ofObject

Added in API level 21
ObjectAnimator ofObject (T target, 
                Property<T, P> property, 
                TypeConverter<V, P> converter, 
                TypeEvaluator<V> evaluator, 
                V... values)

构造并返回在Object值之间动画的ObjectAnimator。 单个值意味着该值是被动画的值,在这种情况下,首次调用start()时, start()正在动画的属性和目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。 此变体提供一个TypeConverter以将动画值转换为属性的类型。 如果仅提供一个值,则TypeConverter必须是BidirectionalTypeConverter才能检索当前值。

注意:这些值存储为对原始对象的引用,这意味着调用此方法后对这些对象的更改将影响动画器上的值。 如果在调用此方法后对象将在外部发生变化,则调用者应该传递这些对象的副本。

Parameters
target T: The object whose property is to be animated.
property Property: The property being animated.
converter TypeConverter: Converts the animated object to the Property type.
evaluator TypeEvaluator: A TypeEvaluator that will be called on each animation frame to provide the necessary interpolation between the Object values to derive the animated value.
values V: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofObject

Added in API level 11
ObjectAnimator ofObject (Object target, 
                String propertyName, 
                TypeEvaluator evaluator, 
                Object... values)

构造并返回在Object值之间动画的ObjectAnimator。 一个值意味着该值是被动画的值,在这种情况下,首次调用start()时, start()被动画的属性和目标对象start() 两个值意味着开始和结束值。 超过两个值意味着一个起始值,沿途动画的值和一个结束值(这些值将在动画的持续时间内均匀分布)。

注意:这些值存储为对原始对象的引用,这意味着调用此方法后对这些对象的更改将影响动画器上的值。 如果在调用此方法后对象将在外部发生变化,则调用者应该传递这些对象的副本。

Parameters
target Object: The object whose property is to be animated. This object should have a public method on it called setName(), where name is the value of the propertyName parameter.
propertyName String: The name of the property being animated.
evaluator TypeEvaluator: A TypeEvaluator that will be called on each animation frame to provide the necessary interpolation between the Object values to derive the animated value.
values Object: A set of values that the animation will animate between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

ofPropertyValuesHolder

Added in API level 11
ObjectAnimator ofPropertyValuesHolder (Object target, 
                PropertyValuesHolder... values)

构造并返回一个ObjectAnimator,它在PropertyValueHolder对象中指定的值集之间进行动画PropertyValueHolder 由于PropertyValuesHolder允许您将一组动画值与一个属性名称相关联,因此应该在使用同一个ObjectAnimator同时动画多个属性时使用此变体。

Parameters
target Object: The object whose property is to be animated. Depending on how the PropertyValuesObjects were constructed, the target object should either have the Property objects used to construct the PropertyValuesHolder objects or (if the PropertyValuesHOlder objects were created with property names) the target object should have public methods on it called setName(), where name is the name of the property passed in as the propertyName parameter for each of the PropertyValuesHolder objects.
values PropertyValuesHolder: A set of PropertyValuesHolder objects whose values will be animated between over time.
Returns
ObjectAnimator An ObjectAnimator object that is set up to animate between the given values.

setAutoCancel

Added in API level 18
void setAutoCancel (boolean cancel)

autoCancel控制是否在启动具有相同目标和属性的任何其他ObjectAnimator时自动取消ObjectAnimator。 设置这个标志可以让在同一个目标对象上运行不同的动画师变得更加容易,而无需跟踪是否存在需要手动取消的动画冲突。 取消动画制作人员必须以相同的顺序具有相同的目标属性。

Parameters
cancel boolean: Whether future ObjectAnimators with the same target and properties as this ObjectAnimator will cause this ObjectAnimator to be canceled.

setDuration

Added in API level 11
ObjectAnimator setDuration (long duration)

设置动画的长度。 默认持续时间是300毫秒。

Parameters
duration long: The length of the animation, in milliseconds.
Returns
ObjectAnimator ObjectAnimator The object called with setDuration(). This return value makes it easier to compose statements together that construct and then set the duration, as in ObjectAnimator.ofInt(target, propertyName, 0, 10).setDuration(500).start().

setFloatValues

Added in API level 11
void setFloatValues (float... values)

设置将在之间动画的浮动值。 一个单一的价值意味着那个价值是被动画的价值。 但是,这在ValueAnimator对象中通常不会有用,因为对象无法确定动画的起始值(与ObjectAnimator不同,后者可以从目标对象和属性进行动画获取该值)。 因此,通常应该有两个或更多的值。

如果已经通过多个PropertyValuesHolder对象为此ValueAnimator定义了多组值,则此方法将为这些对象中的第一个设置值。

Parameters
values float: A set of values that the animation will animate between over time.

setIntValues

Added in API level 11
void setIntValues (int... values)

设置将在之间进行动画处理的int值。 一个单一的价值意味着那个价值是被动画的价值。 但是,这在ValueAnimator对象中通常不会有用,因为对象无法确定动画的起始值(与ObjectAnimator不同,后者可以从目标对象和属性进行动画获取该值)。 因此,通常应该有两个或更多的值。

如果已经通过多个PropertyValuesHolder对象为此ValueAnimator定义了多组值,则此方法将为这些对象中的第一个设置值。

Parameters
values int: A set of values that the animation will animate between over time.

setObjectValues

Added in API level 11
void setObjectValues (Object... values)

为此动画设置动画值。 一个单一的价值意味着那个价值是被动画的价值。 但是,这在ValueAnimator对象中通常不会有用,因为对象无法确定动画的起始值(与ObjectAnimator不同,后者可以从目标对象和属性进行动画获取该值)。 因此,通常应该有两个或更多的值。

注意: Object值存储为对原始对象的引用,这意味着调用此方法后对这些对象的更改将影响动画器上的值。 如果在调用此方法后对象将在外部发生变化,则调用者应该传递这些对象的副本。

如果已经通过多个PropertyValuesHolder对象为此ValueAnimator定义了多组值,则此方法将为这些对象中的第一个设置值。

在ValueAnimator上应该有一个TypeEvaluator,它知道如何在这些值对象之间进行插值。 ValueAnimator只知道如何在其他setValues()方法中指定的基本类型之间进行插值。

Parameters
values Object: The set of values to animate between.

setProperty

Added in API level 14
void setProperty (Property property)

设置将被动画的属性。 属性对象将优先于由setPropertyName(String)方法指定的属性。 动画应该设置为使用一个或另一个,而不是两个。

Parameters
property Property: The property being animated. Should not be null.

setPropertyName

Added in API level 11
void setPropertyName (String propertyName)

设置将要动画的属性的名称。 这个名字被用来派生一个setter函数来调用设置动画值。 例如,属性名称foo将导致调用目标对象上的函数setFoo() 如果valueFromvalueTo为空,那么getter函数也将被派生并调用。

为了获得调用由动画属性名称确定的setter函数的最佳性能,请使用floatint键入的值,并使这些属性的setter函数具有void返回值。 这将导致代码为这些受限制的情况采取优化路径。 其他属性类型和返回类型将起作用,但由于正常的反射机制,在处理请求时会有更多开销。

请注意,从此属性名派生的setter函数必须采用与 valueFromvalueTo属性相同的参数类型,否则对setter函数的调用将失败。

如果此ObjectAnimator已设置为使用多个PropertyValuesHolder对象一起动画多个属性,则设置propertyName只需在第一个PropertyValuesHolder对象中设置propertyName。

Parameters
propertyName String: The name of the property being animated. Should not be null.

setTarget

Added in API level 11
void setTarget (Object target)

设置其属性将由此动画制作动画的目标对象。 并非所有子类都对目标对象进行操作(例如, ValueAnimator ,但此方法位于超类上,以方便与处理目标的子类进行通用处理。

注意:目标被内部存储为弱引用,以避免动画师直接引用旧目标而导致资源泄漏。 因此,你应该确保动画师的目标总是在其他地方有一个很好的参考。

Parameters
target Object: The object being animated

setupEndValues

Added in API level 11
void setupEndValues ()

此方法告诉对象使用适当的信息来提取动画的结尾值。 例如,一个AnimatorSet对象会将这个调用传递给它的子对象,告诉它们设置这些值。 ObjectAnimator对象将使用它所拥有的关于其目标对象和PropertyValuesHolder对象的信息来获取其属性的起始值。 ValueAnimator对象将忽略该请求,因为它没有足够的信息(如目标对象)来收集这些值。

setupStartValues

Added in API level 11
void setupStartValues ()

该方法告诉对象使用适当的信息来提取动画的起始值。 例如,一个AnimatorSet对象会将这个调用传递给它的子对象,告诉它们设置这些值。 ObjectAnimator对象将使用它所拥有的关于其目标对象和PropertyValuesHolder对象的信息来获取其属性的起始值。 ValueAnimator对象将忽略该请求,因为它没有足够的信息(如目标对象)来收集这些值。

start

Added in API level 11
void start ()

开始这个动画。 如果动画具有非零的startDelay,则动画将在延迟消逝后开始运行。 非延迟动画将立即设置其初始值,然后为该动画onAnimationStart(Animator)的任何听众调用onAnimationStart(Animator)

通过调用此方法开始的动画将在调用此方法的线程上运行。 这个线程应该有一个Looper(如果不是这种情况,将会抛出一个运行时异常)。 此外,如果动画会为视图层次结构中的对象的属性制作动画,则调用线程应该是该视图层次结构的UI线程。

toString

Added in API level 11
String toString ()

返回对象的字符串表示形式。 通常, toString方法将返回一个字符串,用于“文本地表示”此对象。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。

ObjecttoString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

Hooray!