MotionLayoutState


@ExperimentalMotionApi
interface MotionLayoutState


Class used to read and manipulate the state of a MotionLayout Composable.

Summary

Public functions

Unit
animateTo(
    newProgress: @FloatRange(from = 0.0, to = 1.0) Float,
    animationSpec: AnimationSpec<Float>
)

Animate the progress to the given newProgress using animationSpec.

Unit

Change the debugging mode.

Unit
snapTo(newProgress: @FloatRange(from = 0.0, to = 1.0) Float)

Set the animation progress to the given newProgress without animating.

Public properties

Float

Observable value for the animation progress of the current MotionLayout Transition.

Boolean

Observable value to indicate if MotionLayout is in a debugging mode.

Public functions

animateTo

fun animateTo(
    newProgress: @FloatRange(from = 0.0, to = 1.0) Float,
    animationSpec: AnimationSpec<Float>
): Unit

Animate the progress to the given newProgress using animationSpec.

Repeated calls to this method will cancel previous ongoing animations.

setDebugMode

fun setDebugMode(motionDebugFlag: MotionLayoutDebugFlags): Unit

Change the debugging mode.

Note that this causes an internal recomposition of the MotionLayout modifiers, cancelling events like swipe handling. Also, debugging may add overhead to measuring and/or drawing.

Set MotionLayoutDebugFlags.NONE to deactivate any ongoing debugging.

snapTo

fun snapTo(newProgress: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Set the animation progress to the given newProgress without animating. The value change will be instant.

Calls to this method will cancel any ongoing animation.

Public properties

currentProgress

val currentProgressFloat

Observable value for the animation progress of the current MotionLayout Transition.

Where 0.0f is the start of the Transition.

And 1.0f is the end of the Transition.

Beware that reading a 0 or 1 does not imply that a Transition animation has ended.

isInDebugMode

val isInDebugModeBoolean

Observable value to indicate if MotionLayout is in a debugging mode.

False by default.