{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

AnimationScope

public final class AnimationScope<T extends Object, V extends AnimationVector>


AnimationScope provides all the animation related info specific to an animation run. An AnimationScope will be accessible during an animation.

See also
animateTo

Summary

Public methods

final void

Cancels the animation that this AnimationScope corresponds to.

final long

The time when the animation finished successfully in the System.nanoTime timebase.

final long

Last frame time of the animation.

final long

Start time of the animation in the System.nanoTime timebase.

final @NonNull T

Target value of the animation.

final @NonNull TwoWayConverter<@NonNull T, @NonNull V>

TwoWayConverter to convert type T from and to AnimationVector.

final @NonNull T

Current value of the AnimationScope.

final @NonNull T

Velocity of type T, converted from velocityVector.

final @NonNull V

Current velocity vector of the AnimationScope.

final boolean

Indicates whether the animation is currently running.

final @NonNull AnimationState<@NonNull T, @NonNull V>

Creates an AnimationState that populates all the fields in AnimationState from AnimationScope.

Public methods

cancelAnimation

public final void cancelAnimation()

Cancels the animation that this AnimationScope corresponds to. The scope will not be updated any more after cancelAnimation is called.

getFinishedTimeNanos

public final long getFinishedTimeNanos()

The time when the animation finished successfully in the System.nanoTime timebase.

If the animation has never finished (i.e. currently running, interrupted, or never started), this will be AnimationConstants.UnspecifiedTime, unless specified otherwise in AnimationState constructor.

getLastFrameTimeNanos

public final long getLastFrameTimeNanos()

Last frame time of the animation.

If the animation has never started, this will be AnimationConstants.UnspecifiedTime, unless specified otherwise in the AnimationState constructor. lastFrameTimeNanos is the frame time when the animation is last updated, in the System.nanoTime timebase. It is also used for starting a sequential animation in AnimationState.animateTo. This allows the sequential animation to set its start time to when the previous animation is interrupted or finished.

getStartTimeNanos

public final long getStartTimeNanos()

Start time of the animation in the System.nanoTime timebase.

getTargetValue

public final @NonNullgetTargetValue()

Target value of the animation.

getTypeConverter

public final @NonNull TwoWayConverter<@NonNull T, @NonNull V> getTypeConverter()

TwoWayConverter to convert type T from and to AnimationVector.

getValue

public final @NonNullgetValue()

Current value of the AnimationScope.

getVelocity

public final @NonNullgetVelocity()

Velocity of type T, converted from velocityVector.

getVelocityVector

public final @NonNullgetVelocityVector()

Current velocity vector of the AnimationScope.

isRunning

public final boolean isRunning()

Indicates whether the animation is currently running.

toAnimationState

public final @NonNull AnimationState<@NonNull T, @NonNull V> toAnimationState()

Creates an AnimationState that populates all the fields in AnimationState from AnimationScope.