The Android Developer Challenge is back! Submit your idea before December 2.

DynamicTargetAnimation

interface DynamicTargetAnimation<T>
androidx.animation.DynamicTargetAnimation

Dynamic target animation allows and anticipates the animation target to change frequently. When the target changes as the animation is in-flight, the animation is expected to make a continuous transition to the new target.

Summary

Public methods

abstract Unit
animateTo(targetValue: T)

abstract Unit
animateTo(targetValue: T, onEnd: (endReason: AnimationEndReason, endValue: T) -> Unit)

abstract Unit
animateTo(targetValue: T, anim: AnimationBuilder<T> = PhysicsBuilder())

abstract Unit
animateTo(targetValue: T, anim: AnimationBuilder<T> = PhysicsBuilder(), onEnd: (endReason: AnimationEndReason, endValue: T) -> Unit)

Sets the target value, which effectively starts an animation to change the value from value to the target value.

abstract Unit
snapTo(targetValue: T)

Sets the current value to the target value immediately, without any animation.

abstract Unit

Stops any on-going animation.

Properties

abstract Boolean

Indicates whether the animation is running.

abstract T

The target of the current animation.

abstract T

Current value of the animation.

Public methods

animateTo

abstract fun animateTo(targetValue: T
): Unit

animateTo

abstract fun animateTo(
    targetValue: T,
    onEnd: (endReason: AnimationEndReason, endValue: T) -> Unit
): Unit

animateTo

abstract fun animateTo(
    targetValue: T,
    anim: AnimationBuilder<T> = PhysicsBuilder()
): Unit

animateTo

abstract fun animateTo(
    targetValue: T,
    anim: AnimationBuilder<T> = PhysicsBuilder(),
    onEnd: (endReason: AnimationEndReason, endValue: T) -> Unit
): Unit

Sets the target value, which effectively starts an animation to change the value from value to the target value. If there is already an animation in flight, this method will interrupt the ongoing animation, invoke onEnd that is associated with that animation, and start a new animation from the current value to the new target value.

Parameters
targetValue: T = null: T The new value to animate to
anim: AnimationBuilder<T> = PhysicsBuilder(): AnimationBuilder<T> = PhysicsBuilder() The animation that will be used to animate from the current value to the new target value
onEnd: (endReason: AnimationEndReason, endValue: T) -> Unit = null: (endReason: AnimationEndReason, endValue: T) -> Unit A callback that will be invoked when the animation finished by any reason.

snapTo

abstract fun snapTo(targetValue: T
): Unit

Sets the current value to the target value immediately, without any animation.

Parameters
targetValue: T = null: T The new target value to set value to.

stop

abstract fun stop(): Unit

Stops any on-going animation. No op if no animation is running. Note that this method does not skip the animation value to its target value. Rather the animation will be stopped in its track.

Properties

isRunning

abstract val isRunning: Boolean

Indicates whether the animation is running.

targetValue

abstract val targetValue: T

The target of the current animation. This target will not be the same as the value of the animation, until the animation finishes un-interrupted.

value

abstract val value: T

Current value of the animation.