TimeAnimator


class TimeAnimator : ValueAnimator


This class provides a simple callback mechanism to listeners that is synchronized with all other animators in the system. There is no duration, interpolation, or object value-setting with this Animator. Instead, it is simply started, after which it proceeds to send out events on every animation frame to its TimeListener (if set), with information about this animator, the total elapsed time, and the elapsed time since the previous animation frame.

Summary

Nested types

Implementors of this interface can set themselves as update listeners to a TimeAnimator instance to receive callbacks on every animation frame to receive the total time since the animator started and the delta time since the last frame.

Public constructors

Public functions

Unit

Sets the position of the animation to the specified point in time.

Unit

Sets a listener that is sent update events throughout the life of an animation.

Unit

Starts this animation.

Inherited Constants

From androidx.core.animation.Animator
const Long

The value used to indicate infinite duration (e.g. when Animators repeat infinitely).

From androidx.core.animation.ValueAnimator
const Int

This value used used with the setRepeatCount property to repeat the animation indefinitely.

const Int

When the animation reaches the end and repeatCount is INFINITE or a positive value, the animation restarts from the beginning.

const Int

When the animation reaches the end and repeatCount is INFINITE or a positive value, the animation reverses direction on every iteration.

Inherited functions

From androidx.core.animation.Animator
Unit

Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

Unit

Adds a pause listener to this animator.

Unit

Adds a listener to the set of listeners that are sent update events through the life of an animation.

Animator
Boolean

Returns whether this animator is currently in a paused state.

Unit

Removes all listeners and pauseListeners from this object.

Unit

Removes all listeners from the set listening to frame updates for this animation.

Unit

Removes a listener from the set listening to this animation.

Unit

Removes a pause listener from the set listening to this animation.

Unit

Removes a listener from the set listening to frame updates for this animation.

abstract Animator
setDuration(duration: @IntRange(from = 0) Long)

Sets the duration of the animation.

abstract Unit
setStartDelay(startDelay: @IntRange(from = 0) Long)

The amount of time, in milliseconds, to delay processing the animation after start is called.

Unit
setTarget(target: Any?)

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

Unit

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

Unit

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

From androidx.core.animation.ValueAnimator
java-static Boolean

Returns whether animators are currently enabled, system-wide.

Unit

Cancels the animation.

ValueAnimator
Unit
end()

Ends the animation.

Float

Returns the current animation fraction, which is the elapsed/interpolated fraction used in the most recent frame update on the animation.

Any

The most recent value calculated by this ValueAnimator when there is just one property being animated.

Any?
getAnimatedValue(propertyName: String)

The most recent value calculated by this ValueAnimator for propertyName.

Long

Gets the current position of the animation in time, which is equal to the current time minus the time that the animation started.

Long

Gets the length of the animation.

java-static Long

The amount of time, in milliseconds, between each frame of the animation.

Interpolator?

Returns the timing interpolator that this ValueAnimator uses.

String

Returns the name of this animator for debugging purposes.

Int

Defines how many times the animation should repeat.

Int

Defines what this animation should do when it reaches the end.

Long

The amount of time, in milliseconds, to delay starting the animation after start is called.

Long

Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating.

Array<PropertyValuesHolder!>

Returns the values that this ValueAnimator animates between.

Boolean

Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).

Boolean

Returns whether this Animator has been started and not yet ended.

java-static ValueAnimator
ofArgb(values: IntArray)

Constructs and returns a ValueAnimator that animates between color values.

java-static ValueAnimator

Constructs and returns a ValueAnimator that animates between float values.

java-static ValueAnimator
ofInt(values: IntArray)

Constructs and returns a ValueAnimator that animates between int values.

java-static ValueAnimator
ofObject(evaluator: TypeEvaluator, values: Array<Any!>)

Constructs and returns a ValueAnimator that animates between Object values.

java-static ValueAnimator

Constructs and returns a ValueAnimator that animates between the values specified in the PropertyValuesHolder objects.

Unit

Pauses a running animation.

Unit

Resumes a paused animation, causing the animator to pick up where it left off when it was paused.

Unit

Plays the ValueAnimator in reverse.

Unit

Sets the position of the animation to the specified fraction.

ValueAnimator
setDuration(duration: Long)

Sets the length of the animation.

Unit

The type evaluator to be used when calculating the animated values of this animation.

Unit

Sets float values that will be animated between.

java-static Unit
setFrameDelay(frameDelay: Long)

The amount of time, in milliseconds, between each frame of the animation.

Unit

Sets int values that will be animated between.

Unit

The interpolator used in calculating the elapsed fraction of this animation.

Unit
setNameForTrace(animationName: String)

Sets a name for the animation to show up in the systrace.

Unit

Sets the values to animate between for this animation.

Unit

Sets how many times the animation should be repeated.

Unit

Defines what this animation should do when it reaches the end.

Unit
setStartDelay(startDelay: Long)

The amount of time, in milliseconds, to delay starting the animation after start is called.

Unit

Sets the values, per property, being animated between.

String

Public constructors

TimeAnimator

TimeAnimator()

Public functions

setCurrentPlayTime

fun setCurrentPlayTime(playTime: Long): Unit

Sets the position of the animation to the specified point in time. This time should be between 0 and the total duration of the animation, including any repetition. If the animation has not yet been started, then it will not advance forward after it is set to this time; it will simply set the time to this value and perform any appropriate actions based on that time. If the animation is already running, then setCurrentPlayTime() will set the current playing time to this value and continue playing from that point.

Parameters
playTime: Long

The time, in milliseconds, to which the animation is advanced or rewound.

setTimeListener

fun setTimeListener(listener: TimeAnimator.TimeListener?): Unit

Sets a listener that is sent update events throughout the life of an animation.

Parameters
listener: TimeAnimator.TimeListener?

the listener to be set.

start

fun start(): Unit

Starts this animation. If the animation has a nonzero startDelay, the animation will start running after that delay elapses. A non-delayed animation will have its initial value(s) set immediately, followed by calls to onAnimationStart for any listeners of this animator.

The animation started by calling this method will be run on the thread that called this method. This thread should have a Looper on it (a runtime exception will be thrown if this is not the case). Also, if the animation will animate properties of objects in the view hierarchy, then the calling thread should be the UI thread for that view hierarchy.