Keyframe

public abstract class Keyframe<T>


This class holds a time/value pair for an animation. The Keyframe class is used by ValueAnimator to define the values that the animation target will have over the course of the animation. As the time proceeds from one keyframe to the other, the value of the target object will animate between the value at the previous keyframe and the value at the next keyframe. Each keyframe also holds an optional Interpolator object, which defines the time interpolation over the intervalue preceding the keyframe.

The Keyframe class itself is abstract. The type-specific factory methods will return a subclass of Keyframe specific to the type of value being stored. This is done to improve performance when dealing with the most common cases (e.g., float and int values). Other types will fall into a more general Keyframe class that treats its values as Objects. Unless your animation requires dealing with a custom type or a data structure that needs to be animated directly (and evaluated using an implementation of TypeEvaluator), you should stick to using float and int as animations using those types have lower runtime overhead than other types.

Parameters
<T>

type of the data value stored in a key frame.

Summary

Public constructors

Public methods

abstract @NonNull @Override Keyframe<T>
@FloatRange(from = 0, to = 1) float

Gets the time for this keyframe, as a fraction of the overall animation duration.

@Nullable Interpolator

Gets the optional interpolator for this Keyframe.

@NonNull Class<Object>

Gets the type of keyframe.

abstract @Nullable T

Gets the value for this Keyframe.

boolean

Indicates whether this keyframe has a valid value.

static @NonNull Keyframe<Float>
ofFloat(@FloatRange(from = 0, to = 1) float fraction, float value)

Constructs a Keyframe object with the given time and value.

static @NonNull Keyframe<Float>
ofFloat(@FloatRange(from = 0, to = 1) float fraction)

Constructs a Keyframe object with the given time.

static @NonNull Keyframe<Integer>
ofInt(@FloatRange(from = 0, to = 1) float fraction, int value)

Constructs a Keyframe object with the given time and value.

static @NonNull Keyframe<Integer>
ofInt(@FloatRange(from = 0, to = 1) float fraction)

Constructs a Keyframe object with the given time.

static @NonNull Keyframe<T>
<T> ofObject(@FloatRange(from = 0, to = 1) float fraction, @Nullable T value)

Constructs a Keyframe object with the given time and value.

static @NonNull Keyframe<T>
<T> ofObject(@FloatRange(from = 0, to = 1) float fraction)

Constructs a Keyframe object wi