PropertyValuesHolder

public class PropertyValuesHolder
extends Object implements Cloneable

java.lang.Object
   ↳ androidx.core.animation.PropertyValuesHolder


This class holds information about a property and the values that that property should take on during an animation. PropertyValuesHolder objects can be used to create animations with ValueAnimator or ObjectAnimator that operate on several different properties in parallel.

Summary

Public methods

PropertyValuesHolder clone()
String getPropertyName()

Gets the name of the property that will be animated.

static PropertyValuesHolder ofFloat(Property<?, Float> property, float... values)

Constructs and returns a PropertyValuesHolder with a given property and set of float values.

static PropertyValuesHolder ofFloat(String propertyName, float... values)

Constructs and returns a PropertyValuesHolder with a given property name and set of float values.

static PropertyValuesHolder ofInt(String propertyName, int... values)

Constructs and returns a PropertyValuesHolder with a given property name and set of int values.

static PropertyValuesHolder ofInt(Property<?, Integer> property, int... values)

Constructs and returns a PropertyValuesHolder with a given property and set of int values.

static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property and set of values.

static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name and set of values.

static PropertyValuesHolder ofMultiFloat(String propertyName, float[][] values)

Constructs and returns a PropertyValuesHolder with a given property name and set of float[] values.

static <V> PropertyValuesHolder ofMultiFloat(String propertyName, TypeConverter<V, float[]> converter, TypeEvaluator<V> evaluator, V... values)

Constructs and returns a PropertyValuesHolder with a given property and set of Object values for use with ObjectAnimator multi-value setters.

static <T> PropertyValuesHolder ofMultiFloat(String propertyName, TypeConverter<T, float[]> converter, TypeEvaluator<T> evaluator, Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name or setter name for use in a multi-float setter function using ObjectAnimator.

static PropertyValuesHolder ofMultiFloat(String propertyName, Path path)

Constructs and returns a PropertyValuesHolder with a given property name to use as a multi-float setter.

static PropertyValuesHolder ofMultiInt(String propertyName, Path path)

Constructs and returns a PropertyValuesHolder with a given property name to use as a multi-int setter.

static PropertyValuesHolder ofMultiInt(String propertyName, int[][] values)

Constructs and returns a PropertyValuesHolder with a given property name and set of int[] values.

static <T> PropertyValuesHolder ofMultiInt(String propertyName, TypeConverter<T, int[]> converter, TypeEvaluator<T> evaluator, Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name or setter name for use in a multi-int setter function using ObjectAnimator.

static <V> PropertyValuesHolder ofMultiInt(String propertyName, TypeConverter<V, int[]> converter, TypeEvaluator<V> evaluator, V... values)

Constructs and returns a PropertyValuesHolder with a given property and set of Object values for use with ObjectAnimator multi-value setters.

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

Constructs and returns a PropertyValuesHolder with a given property name and set of Object values.

static PropertyValuesHolder ofObject(String propertyName, TypeConverter<PointF, ?> converter, Path path)

Constructs and returns a PropertyValuesHolder with a given property name and a Path along which the values should be animated.

static <V> PropertyValuesHolder ofObject(Property property, TypeEvaluator<V> evaluator, V... values)

Constructs and returns a PropertyValuesHolder with a given property and set of Object values.

static <V> PropertyValuesHolder ofObject(Property<?, V> property, TypeConverter<PointF, V> converter, Path path)

Constructs and returns a PropertyValuesHolder with a given property and a Path along which the values should be animated.

static <T, V> PropertyValuesHolder ofObject(Property<?, V> property, TypeConverter<T, V> converter, TypeEvaluator<T> evaluator, T... values)

Constructs and returns a PropertyValuesHolder with a given property and set of Object values.

void setConverter(TypeConverter converter)

Sets the converter to convert from the values type to the setter's parameter type.

void setEvaluator(TypeEvaluator evaluator)

The TypeEvaluator will be automatically determined based on the type of values supplied to PropertyValuesHolder.

void setFloatValues(float... values)

Set the animated values for this object to this set of floats.

void setIntValues(int... values)

Set the animated values for this object to this set of ints.

void setKeyframes(Keyframe... values)

Set the animated values for this object to this set of Keyframes.

void setObjectValues(Object... values)

Set the animated values for this object to this set of Objects.

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.

String toString()

Inherited methods

Public methods

clone

public PropertyValuesHolder clone ()

Returns
PropertyValuesHolder

getPropertyName

public String getPropertyName ()

Gets the name of the property that will be animated. This name will be used to derive a setter function that will be called to set animated values. For example, a property name of foo will result in a call to the function setFoo() on the target object. If either valueFrom or valueTo is null, then a getter function will also be derived and called.

Returns
String

ofFloat

public static PropertyValuesHolder ofFloat (Property<?, Float> property, 
                float... values)

Constructs and returns a PropertyValuesHolder with a given property and set of float values.

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

values float: The values that the property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofFloat

public static PropertyValuesHolder ofFloat (String propertyName, 
                float... values)

Constructs and returns a PropertyValuesHolder with a given property name and set of float values.

Parameters
propertyName String: The name of the property being animated.

values float: The values that the named property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofInt

public static PropertyValuesHolder ofInt (String propertyName, 
                int... values)

Constructs and returns a PropertyValuesHolder with a given property name and set of int values.

Parameters
propertyName String: The name of the property being animated.

values int: The values that the named property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofInt

public static PropertyValuesHolder ofInt (Property<?, Integer> property, 
                int... values)

Constructs and returns a PropertyValuesHolder with a given property and set of int values.

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

values int: The values that the property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofKeyframe

public static PropertyValuesHolder ofKeyframe (Property property, 
                Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property and set of values. These values can be of any type, but the type should be consistent so that an appropriate TypeEvaluator can be found that matches the common type.

If there is only one value, it is assumed to be the end value of an animation, and an initial value will be derived, if possible, by calling the property's Property.get(Object) function. Also, if any value is null, the value will be filled in when the animation starts in the same way. This mechanism of automatically getting null values only works if the PropertyValuesHolder object is used in conjunction with ObjectAnimator, since otherwise PropertyValuesHolder has no way of determining what the value should be.

Parameters
property Property: The property associated with this set of values. Should not be null.

values Keyframe: The set of values to animate between.

Returns
PropertyValuesHolder

ofKeyframe

public static PropertyValuesHolder ofKeyframe (String propertyName, 
                Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name and set of values. These values can be of any type, but the type should be consistent so that an appropriate TypeEvaluator can be found that matches the common type.

If there is only one value, it is assumed to be the end value of an animation, and an initial value will be derived, if possible, by calling a getter function on the object. Also, if any value is null, the value will be filled in when the animation starts in the same way. This mechanism of automatically getting null values only works if the PropertyValuesHolder object is used in conjunction ObjectAnimator, and with a getter function derived automatically from propertyName, since otherwise PropertyValuesHolder has no way of determining what the value should be.

Parameters
propertyName String: The name of the property associated with this set of values. This can be the actual property name to be used when using a ObjectAnimator object, or just a name used to get animated values, such as if this object is used with an ValueAnimator object.

values Keyframe: The set of values to animate between.

Returns
PropertyValuesHolder

ofMultiFloat

public static PropertyValuesHolder ofMultiFloat (String propertyName, 
                float[][] values)

Constructs and returns a PropertyValuesHolder with a given property name and set of float[] values. At least two float[] values must be supplied, a start and end value. If more values are supplied, the values will be animated from the start, through all intermediate values to the end value. When used with ObjectAnimator, the elements of the array represent the parameters of the setter function.

Parameters
propertyName String: The name of the property being animated. Can also be the case-sensitive name of the entire setter method. Should not be null.

values float: The values that the property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofMultiFloat

public static PropertyValuesHolder ofMultiFloat (String propertyName, 
                TypeConverter<V, float[]> converter, 
                TypeEvaluator<V> evaluator, 
                V... values)

Constructs and returns a PropertyValuesHolder with a given property and set of Object values for use with ObjectAnimator multi-value setters. The Object values are converted to float[] using the converter.

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

converter TypeConverter: Used to convert the animated value to setter parameters.

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: The values that the property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofMultiFloat

public static PropertyValuesHolder ofMultiFloat (String propertyName, 
                TypeConverter<T, float[]> converter, 
                TypeEvaluator<T> evaluator, 
                Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name or setter name for use in a multi-float setter function using ObjectAnimator. The values can be of any type, but the type should be consistent so that the supplied TypeEvaluator can be used to to evaluate the animated value. The converter converts the values to parameters in the setter function.

At least two values must be supplied, a start and an end value.

Parameters
propertyName String: The name of the property to associate with the set of values. This may also be the complete name of a setter function.

converter TypeConverter: Converts values into float parameters for the setter. Can be null if the Keyframes have float[] values.

evaluator TypeEvaluator: Used to interpolate between values.

values Keyframe: The values at specific fractional times to evaluate between

Returns
PropertyValuesHolder A PropertyValuesHolder for a multi-float parameter setter.

ofMultiFloat

public static PropertyValuesHolder ofMultiFloat (String propertyName, 
                Path path)

Constructs and returns a PropertyValuesHolder with a given property name to use as a multi-float setter. The values are animated along the path, with the first parameter of the setter set to the x coordinate and the second set to the y coordinate.

Parameters
propertyName String: The name of the property being animated. Can also be the case-sensitive name of the entire setter method. Should not be null. The setter must take exactly two float parameters.

path Path: The Path along which the values should be animated.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofMultiInt

public static PropertyValuesHolder ofMultiInt (String propertyName, 
                Path path)

Constructs and returns a PropertyValuesHolder with a given property name to use as a multi-int setter. The values are animated along the path, with the first parameter of the setter set to the x coordinate and the second set to the y coordinate.

Parameters
propertyName String: The name of the property being animated. Can also be the case-sensitive name of the entire setter method. Should not be null. The setter must take exactly two int parameters.

path Path: The Path along which the values should be animated.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofMultiInt

public static PropertyValuesHolder ofMultiInt (String propertyName, 
                int[][] values)

Constructs and returns a PropertyValuesHolder with a given property name and set of int[] values. At least two int[] values must be supplied, a start and end value. If more values are supplied, the values will be animated from the start, through all intermediate values to the end value. When used with ObjectAnimator, the elements of the array represent the parameters of the setter function.

Parameters
propertyName String: The name of the property being animated. Can also be the case-sensitive name of the entire setter method. Should not be null.

values int: The values that the property will animate between.

Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofMultiInt

public static PropertyValuesHolder ofMultiInt (String propertyName, 
                TypeConverter<T, int[]> converter, 
                TypeEvaluator<T> evaluator, 
                Keyframe... values)

Constructs and returns a PropertyValuesHolder object with the specified property name or setter name for use in a multi-int setter function using ObjectAnimator. The values can be of any type, but the type should be consistent so that the supplied TypeEvaluator can be used to to evaluate the animated value. The converter converts the values to parameters in the setter function.

At least two values must be supplied, a start and an end value.

Parameters
propertyName String: The name of the property to associate with the set of values. This may also be the complete name of a setter function.

converter TypeConverter: Converts values into int parameters for the setter. Can be null if the Keyframes have int[] values.

evaluator TypeEvaluator: Used to interpolate between values.

values Keyframe: The values at specific fractional times to evaluate between

Returns
PropertyValuesHolder A PropertyValuesHolder for a multi-int parameter setter.

ofMultiInt

public static PropertyValuesHolder ofMultiInt (String propertyName, 
                TypeConverter<V, int[]> converter, 
                TypeEval