Most visited

Recently visited

Added in API level 11

PropertyValuesHolder

public class PropertyValuesHolder
extends Object implements Cloneable

java.lang.Object
   ↳ android.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()

Creates and returns a copy of this object.

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(String propertyName, Keyframe... values)

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

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

Constructs and returns a PropertyValuesHolder object with the specified property 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 PropertyValuesHolder ofMultiFloat(String propertyName, Path path)

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

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 ofMultiInt(String propertyName, Path path)

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

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 ofMultiInt(String propertyName, int[][] values)

Constructs and returns a PropertyValuesHolder with a given property name and set of int[] 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 PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator, Object... values)

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

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.

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.

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()

Returns a string representation of the object.

Inherited methods

From class java.lang.Object

Public methods

clone

Added in API level 11
PropertyValuesHolder clone ()

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

 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.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable and that the return type of the clone method of an array type T[] is T[] where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

The class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time.

Returns
PropertyValuesHolder a clone of this instance.

getPropertyName

Added in API level 11
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

Added in API level 14
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

Added in API level 11
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

Added in API level 11
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

Added in API level 14
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

Added in API level 11
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

ofKeyframe

Added in API level 14
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 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

ofMultiFloat

Added in API level 21
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.

See also:

ofMultiFloat

Added in API level 21
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.

See also:

ofMultiFloat

Added in API level 21
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.

See also:

ofMultiFloat

Added in API level 21
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.

ofMultiInt

Added in API level 21
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.

See also:

ofMultiInt

Added in API level 21
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

Added in API level 21
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. The Object values are converted to int[] 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.

See also:

ofMultiInt

Added in API level 21
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.

See also:

ofObject

Added in API level 21
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. This variant supports a TypeConverter to convert from PointF to the target type.

The PointF passed to converter or property, if converter is null, is reused on each animation frame and should not be stored by the setter or TypeConverter.

Parameters
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 along which the values should be animated.
Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofObject

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

Constructs and returns a PropertyValuesHolder with a given property name and set of Object values. This variant also takes a TypeEvaluator because the system cannot automatically interpolate between objects of unknown type.

Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.

Parameters
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: The values that the named property will animate between.
Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

ofObject

Added in API level 21
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. This variant also takes a TypeEvaluator because the system cannot automatically interpolate between objects of unknown type. This variant also takes a TypeConverter to convert from animated values to the type of the property. If only one value is supplied, the TypeConverter must be a BidirectionalTypeConverter to retrieve the current value.

Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.

Parameters
property Property: The property being animated. Should not be null.
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 T: The values that the property will animate between.
Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

See also:

ofObject

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

Constructs and returns a PropertyValuesHolder with a given property and set of Object values. This variant also takes a TypeEvaluator because the system cannot automatically interpolate between objects of unknown type.

Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.

Parameters
property Property: The property being animated. Should not be null.
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.

ofObject

Added in API level 21
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. This variant supports a TypeConverter to convert from PointF to the target type.

The PointF passed to converter or property, if converter is null, is reused on each animation frame and should not be stored by the setter or TypeConverter.

Parameters
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 along which the values should be animated.
Returns
PropertyValuesHolder PropertyValuesHolder The constructed PropertyValuesHolder object.

setConverter

Added in API level 21
void setConverter (TypeConverter converter)

Sets the converter to convert from the values type to the setter's parameter type. If only one value is supplied, converter must be a BidirectionalTypeConverter.

Parameters
converter TypeConverter: The converter to use to convert values.

setEvaluator

Added in API level 11
void setEvaluator (TypeEvaluator evaluator)

The TypeEvaluator will be automatically determined based on the type of values supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so desired. This may be important in cases where either the type of the values supplied do not match the way that they should be interpolated between, or if the values are of a custom type or one not currently understood by the animation system. Currently, only values of type float and int (and their Object equivalents: Float and Integer) are correctly interpolated; all other types require setting a TypeEvaluator.

setFloatValues

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

Set the animated values for this object to this set of floats. 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
values float: One or more values that the animation will animate between.

setIntValues

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

Set the animated values for this object to this set of ints. 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
values int: One or more values that the animation will animate between.

setKeyframes

Added in API level 11
void setKeyframes (Keyframe... values)

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

Parameters
values Keyframe: One or more values that the animation will animate between.

setObjectValues

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

Set the animated values for this object to this set of Objects. 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.

Note: The Object values are stored as references to the original objects, which means that changes to those objects after this method is called will affect the values on the PropertyValuesHolder. If the objects will be mutated externally after this method is called, callers should pass a copy of those objects instead.

Parameters
values Object: One or more values that the animation will animate between.

setProperty

Added in API level 14
void setProperty (Property property)

Sets the property that will be animated.

Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property must exist on the target object specified in that ObjectAnimator.

Parameters
property Property: The property being animated.

setPropertyName

Added in API level 11
void setPropertyName (String propertyName)

Sets the name of the property that will be animated. This name is 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.

Note that the setter function derived from this property name must take the same parameter type as the valueFrom and valueTo properties, otherwise the call to the setter function will fail.

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

toString

Added in API level 11
String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

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

Returns
String a string representation of the object.

Hooray!