Google 致力于为黑人社区推动种族平等。查看具体举措

ObjectAnimator

class ObjectAnimator : ValueAnimator
kotlin.Any
   ↳ 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.

Summary

Inherited constants
Public constructors

Creates a new ObjectAnimator object.

Public methods
ObjectAnimator

String

String

Gets the name of the property that will be animated.

Any?

The target object whose property will be animated by this animation

static ObjectAnimator
ofArgb(@NonNull target: Any, @NonNull propertyName: String, @NonNull vararg values: Int)

Constructs and returns an ObjectAnimator that animates between color values.

static ObjectAnimator
ofArgb(@NonNull target: T, @NonNull property: Property<T, Int!>, @NonNull vararg values: Int)

Constructs and returns an ObjectAnimator that animates between color values.

static ObjectAnimator
ofFloat(@NonNull target: Any, @NonNull propertyName: String, @NonNull vararg values: Float)

Constructs and returns an ObjectAnimator that animates between float values.

static ObjectAnimator
ofFloat(@NonNull target: Any, @Nullable xPropertyName: String?, @Nullable yPropertyName: String?, @NonNull path: Path)

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

static ObjectAnimator
ofFloat(@NonNull target: T, @NonNull property: Property<T, Float!>, @NonNull vararg values: Float)

Constructs and returns an ObjectAnimator that animates between float values.

static ObjectAnimator
ofFloat(@NonNull target: T, @Nullable xProperty: Property<T, Float!>?, @Nullable yProperty: Property<T, Float!>?, @NonNull path: Path)

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

static ObjectAnimator
ofInt(@NonNull target: Any, @NonNull propertyName: String, @NonNull vararg values: Int)

Constructs and returns an ObjectAnimator that animates between int values.

static ObjectAnimator
ofInt(@NonNull target: Any, @NonNull xPropertyName: String, @NonNull yPropertyName: String, @NonNull path: Path)

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

static ObjectAnimator
ofInt(@NonNull target: T, @NonNull property: Property<T, Int!>, @NonNull vararg values: Int)

Constructs and returns an ObjectAnimator that animates between int values.

static ObjectAnimator
ofInt(@NonNull target: T, @Nullable xProperty: Property<T, Int!>?, @Nullable yProperty: Property<T, Int!>?, @NonNull path: Path)

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

static ObjectAnimator
ofMultiFloat(@NonNull target: Any, @NonNull propertyName: String, @NonNull values: Array<FloatArray!>)

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

static ObjectAnimator
ofMultiFloat(@NonNull target: Any, @NonNull propertyName: String, @NonNull path: Path)

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

static ObjectAnimator
ofMultiFloat(@NonNull target: Any, @NonNull propertyName: String, @NonNull converter: TypeConverter<T, FloatArray!>, @NonNull evaluator: TypeEvaluator<T>, @NonNull vararg values: T)

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

static ObjectAnimator
ofMultiInt(@NonNull target: Any, @NonNull propertyName: String, @NonNull values: Array<IntArray!>)

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

static ObjectAnimator
ofMultiInt(@NonNull target: Any, @NonNull propertyName: String, @NonNull path: Path)

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

static ObjectAnimator
ofMultiInt(@NonNull target: Any, @NonNull propertyName: String, @NonNull converter: TypeConverter<T, IntArray!>, @NonNull evaluator: TypeEvaluator<T>, @NonNull vararg values: T)

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

static ObjectAnimator
ofObject(@NonNull target: Any, @NonNull propertyName: String, @NonNull evaluator: TypeEvaluator<Any!>, @NonNull vararg values: Any!)

Constructs and returns an ObjectAnimator that animates between Object values.

static ObjectAnimator
ofObject(@NonNull target: Any, @NonNull propertyName: String, @Nullable converter: TypeConverter<PointF!, *>?, @NonNull path: Path)

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

static ObjectAnimator
ofObject(@NonNull target: T, @NonNull property: Property<T, V>, @NonNull evaluator: TypeEvaluator<V>, @NonNull vararg values: V)

Constructs and returns an ObjectAnimator that animates between Object values.

static ObjectAnimator
ofObject(@NonNull target: T, @NonNull property: Property<T, P>, @NonNull converter: TypeConverter<V, P>, @NonNull evaluator: TypeEvaluator<V>, @NonNull vararg values: V)

Constructs and returns an ObjectAnimator that animates between Object values.

static ObjectAnimator
ofObject(@NonNull target: T, @NonNull property: Property<T, V>, @Nullable converter: TypeConverter<PointF!, V>?, @NonNull path: Path)

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

static ObjectAnimator
ofPropertyValuesHolder(@NonNull target: Any, @NonNull vararg values: PropertyValuesHolder!)

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

Unit

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

ObjectAnimator
setDuration(duration: Long)

Sets the length of the animation.

Unit
setFloatValues(@NonNull vararg values: Float)

Unit
setIntValues(@NonNull vararg values: Int)

Unit
setObjectValues(@NonNull vararg values: Any!)

Unit
setProperty(@NonNull property: Property<Any!, Any!>)

Sets the property that will be animated.

Unit
setPropertyName(@NonNull propertyName: String)

Sets the name of the property that will be animated.

Unit
setTarget(@Nullable target: Any?)

Unit

Unit

Unit

String

Inherited functions