ObjectAnimator

public final class ObjectAnimator
extends ValueAnimator

java.lang.Object
   ↳ androidx.core.animation.Animator
     ↳ androidx.core.animation.ValueAnimator
       ↳ androidx.core.animation.ObjectAnimator


This subclass of ValueAnimator provides support for animating properties on target objects. The constructors of this class take parameters to define the target object that will be animated as well as the name of the property that will be animated. Appropriate set/get functions are then determined internally and the animation will call these functions as necessary to animate the property.

ObjectAnimator supports the use of PropertyValuesHolder and Keyframe in resource files to create more complex animations. Using PropertyValuesHolders allows animators to animate several properties in parallel.

Using Keyframes allows animations to follow more complex paths from the start to the end values. Note that you can specify explicit fractional values (from 0 to 1) for each keyframe to determine when, in the overall duration, the animation should arrive at that value. Alternatively, you can leave the fractions off and the keyframes will be equally distributed within the total duration. Also, a keyframe with no value will derive its value from the target object when the animator starts, just like animators with only one value specified. In addition, an optional interpolator can be specified. The interpolator will be applied on the interval between the keyframe that the interpolator is set on and the previous keyframe. When no interpolator is supplied, the default AccelerateDecelerateInterpolator will be used.

Developer Guides

For more information about animating with ObjectAnimator, read the Property Animation developer guide.

Summary

Inherited constants

Public constructors

ObjectAnimator()

Creates a new ObjectAnimator object.

Public methods

ObjectAnimator clone()
String getNameForTrace()

Returns the name of this animator for debugging purposes.

String getPropertyName()

Gets the name of the property that will be animated.

Object getTarget()

The target object whose property will be animated by this animation

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

Constructs and returns an ObjectAnimator that animates between color values.

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

Constructs and returns an ObjectAnimator that animates between color values.

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

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

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

Constructs and returns an ObjectAnimator that animates between float values.

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

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

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

Constructs and returns an ObjectAnimator that animates between float values.

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

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

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

Constructs and returns an ObjectAnimator that animates between int values.

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

Constructs and returns an ObjectAnimator that animates between int values.

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

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

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

Constructs and returns an ObjectAnimator that animates over float values for a multiple parameters setter.

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

Constructs and returns an ObjectAnimator that animates the target using a multi-float setter along the given Path.

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

Constructs and returns an ObjectAnimator that animates over values for a multiple float parameters setter.

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

Constructs and returns an ObjectAnimator that animates over int values for a multiple parameters setter.

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

Constructs and returns an ObjectAnimator that animates over values for a multiple int parameters setter.

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

Constructs and returns an ObjectAnimator that animates the target using a multi-int setter along the given Path.

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

Constructs and returns an ObjectAnimator that animates between Object values.

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

Constructs and returns an ObjectAnimator that animates between Object values.

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

Constructs and returns an ObjectAnimator that animates a property along a Path.

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

Constructs and returns an ObjectAnimator that animates between Object values.

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

Constructs and returns an ObjectAnimator that animates a property along a Path.

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

Constructs and returns an ObjectAnimator that animates between the sets of values specified in PropertyValueHolder objects.

void setAutoCancel(boolean cancel)

autoCancel controls whether an ObjectAnimator will be canceled automatically when any other ObjectAnimator with the same target and properties is started.

ObjectAnimator setDuration(long duration)

Sets the length of the animation.

void setFloatValues(float... values)

Sets float values that will be animated between.

void setIntValues(int... values)

Sets int values that will be animated between.

void setObjectValues(Object... values)

Sets the values to animate between for this animation.

void setProperty(Property property)

Sets the property that will be animated.

void setPropertyName(String propertyName)

Sets the name of the property that will be animated.

void setTarget(Object target)

Sets the target object whose property will be animated by this animation.

void setupEndValues()

This method tells the object to use appropriate information to extract ending values for the animation.

void setupStartValues()

This method tells the object to use appropriate information to extract starting values for the animation.

void start()

Starts this animation.

String toString()

Inherited methods