Stay organized with collections Save and categorize content based on your preferences.

androidx.constraintlayout.compose

Interfaces

BaselineAnchorable

Represents the FirstBaseline of a layout that can be anchored using linkTo in their Modifier.constrainAs blocks.

ConstraintLayoutTagParentData

ConstraintSet

Immutable description of the constraints used to layout the children of a ConstraintLayout.

DesignInfoProvider

Interface used for Studio tooling.

Dimension

Represents a dimension that can be assigned to the width or height of a ConstraintLayoutConstrainedLayoutReference.

HorizontalAnchorable

Represents a horizontal side of a layout (i.

LayoutInformationReceiver

MotionScene

Information for MotionLayout to animate between multiple ConstraintSets.

Transition

Defines interpolation parameters between two ConstraintSets.

VerticalAnchorable

Represents a vertical side of a layout (i.

Classes

ChainStyle

The style of a horizontal or vertical chain.

ConstrainedLayoutReference

Represents a layout within a ConstraintLayout.

ConstrainScope

Scope that can be used to constrain a layout.

ConstraintLayoutBaseScope

Common scope for ConstraintLayoutScope and ConstraintSetScope, the content being shared between the inline DSL API and the ConstraintSet-based API.

ConstraintLayoutScope

Scope used by the inline DSL of ConstraintLayout.

ConstraintSetScope

Scope used by the ConstraintSet DSL.

HorizontalChainReference

Represents a horizontal chain within a ConstraintLayout.

HorizontalChainScope

MotionLayoutScope

State

The state of the ConstraintLayout solver.

VerticalChainReference

Represents a vertical chain within a ConstraintLayout.

VerticalChainScope

Visibility

The overall visibility of a widget in a ConstraintLayout.

Annotations

ExperimentalMotionApi

Enums

LayoutInfoFlags

MotionLayoutDebugFlags

Top-level functions summary

Unit
ConstraintLayout(modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, crossinline content: ConstraintLayoutScope.() -> Unit)

Layout that positions its children according to the constraints between them.

Unit
ConstraintLayout(constraintSet: ConstraintSet, modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, animateChanges: Boolean = false, animationSpec: AnimationSpec<Float> = tween<Float>(), noinline finishedAnimationListener: () -> Unit = null, noinline content: () -> Unit)

Layout that positions its children according to the constraints between them.

ConstraintSet
ConstraintSet(content: String, overrideVariables: String? = null)

Parses content into a ConstraintSet and sets the variables defined in the Variables block with the values of overrideVariables.

ConstraintSet
ConstraintSet(jsonContent: String)

Parses the given JSON5 into a ConstraintSet.

ConstraintSet
ConstraintSet(extendConstraintSet: ConstraintSet, jsonContent: String)

Creates a ConstraintSet from a jsonContent string that extends the changes applied by extendConstraintSet.

ConstraintSet
ConstraintSet(description: ConstraintSetScope.() -> Unit)

Creates a ConstraintSet.

ConstraintSet
ConstraintSet(extendConstraintSet: ConstraintSet, description: ConstraintSetScope.() -> Unit)

Creates a ConstraintSet that extends the changes applied by extendConstraintSet.

Unit
MotionLayout(start: ConstraintSet, end: ConstraintSet, transition: Transition? = null, progress: Float, debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE), modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, crossinline content: MotionLayoutScope.() -> Unit)

Layout that interpolate its children layout given two sets of constraint and a progress (from 0 to 1)

Unit
MotionLayout(motionScene: MotionScene, progress: Float, debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE), modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, crossinline content: MotionLayoutScope.() -> Unit)

Layout that animates the default transition of a MotionScene with a progress value (from 0 to 1).

Unit
MotionLayout(motionScene: MotionScene, constraintSetName: String? = null, animationSpec: AnimationSpec<Float> = tween<Float>(), debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE), modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, noinline finishedAnimationListener: () -> Unit = null, crossinline content: MotionLayoutScope.() -> Unit)

Layout that takes a MotionScene and animates by providing a constraintSetName to animate to.

Unit
MotionLayout(start: ConstraintSet, end: ConstraintSet, transition: Transition? = null, progress: Float, debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE), informationReceiver: LayoutInformationReceiver? = null, modifier: Modifier = Modifier, optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD, crossinline content: MotionLayoutScope.() -> Unit)

MotionScene
MotionScene(content: String)

Parses the given JSON5 into a MotionScene.

Transition?
Transition(content: String)

Parses the given JSON5 into a Transition.

Top-level properties summary

SemanticsPropertyKey<DesignInfoProvider>

SemanticsPropertyKey to test DesignInfoProvider

Extension functions summary

For androidx.compose.ui.Modifier
Modifier
Modifier.layoutId(layoutId: String, tag: String)

For Coercible
Dimension.MaxCoercible

Sets the lower bound of the current Dimension to a fixed dp value.

Dimension.MinCoercible

Sets the upper bound of the current Dimension to a fixed dp value.

For MinCoercible
Dimension

Sets the lower bound of the current Dimension to a fixed dp value.

Dimension

Sets the lower bound of the current Dimension to a fixed dp value.

For MaxCoercible
Dimension

Sets the upper bound of the current Dimension to a fixed dp value.

Extension properties summary

For androidx.compose.ui.layout.Measurable
Any?
Measurable.constraintLayoutId()

Any?
Measurable.constraintLayoutTag()

For Coercible
Dimension.MaxCoercible

Sets the lower bound of the current Dimension to be the wrap content size of the child.

Dimension.MinCoercible

Sets the upper bound of the current Dimension to be the wrap content size of the child.

For MinCoercible
Dimension

Sets the lower bound of the current Dimension to be the wrap content size of the child.

For MaxCoercible
Dimension

Sets the upper bound of the current Dimension to be the Wrap size of the child.

Top-level functions

ConstraintLayout

@Composable inline fun ConstraintLayout(
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    crossinline content: ConstraintLayoutScope.() -> Unit
): Unit

Layout that positions its children according to the constraints between them.

ConstraintLayout

@Composable inline fun ConstraintLayout(
    constraintSet: ConstraintSet,
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    animateChanges: Boolean = false,
    animationSpec: AnimationSpec<Float> = tween<Float>(),
    noinline finishedAnimationListener: () -> Unit = null,
    noinline content: () -> Unit
): Unit

Layout that positions its children according to the constraints between them.

When recomposed with different constraintSet, you can use the animateChanges parameter to animate the layout changes (animationSpec and finishedAnimationListener attributes can also be useful in this mode). This is only intended for basic transitions, if more control is needed, we recommend using MotionLayout instead.

ConstraintSet

@Composable fun ConstraintSet(
    content: String,
    overrideVariables: String? = null
): ConstraintSet

Parses content into a ConstraintSet and sets the variables defined in the Variables block with the values of overrideVariables.

Eg:

For Variables: { margin: { from: 'initialMargin', step: 10 } }

overrideVariables = "{ 'initialMargin' = 50 }"

Will create a ConstraintSet where initialMargin is 50.

ConstraintSet

fun ConstraintSet(jsonContent: String): ConstraintSet

Parses the given JSON5 into a ConstraintSet.

See the official Github Wiki to learn the syntax.

ConstraintSet

fun ConstraintSet(
    extendConstraintSet: ConstraintSet,
    jsonContent: String
): ConstraintSet

Creates a ConstraintSet from a jsonContent string that extends the changes applied by extendConstraintSet.

ConstraintSet

fun ConstraintSet(description: ConstraintSetScope.() -> Unit): ConstraintSet

Creates a ConstraintSet.

ConstraintSet

fun ConstraintSet(
    extendConstraintSet: ConstraintSet,
    description: ConstraintSetScope.() -> Unit
): ConstraintSet

Creates a ConstraintSet that extends the changes applied by extendConstraintSet.

MotionLayout

@Composable inline fun MotionLayout(
    start: ConstraintSet,
    end: ConstraintSet,
    transition: Transition? = null,
    progress: Float,
    debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    crossinline content: MotionLayoutScope.() -> Unit
): Unit

Layout that interpolate its children layout given two sets of constraint and a progress (from 0 to 1)

MotionLayout

@Composable inline fun MotionLayout(
    motionScene: MotionScene,
    progress: Float,
    debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    crossinline content: MotionLayoutScope.() -> Unit
): Unit

Layout that animates the default transition of a MotionScene with a progress value (from 0 to 1).

MotionLayout

@Composable inline fun MotionLayout(
    motionScene: MotionScene,
    constraintSetName: String? = null,
    animationSpec: AnimationSpec<Float> = tween<Float>(),
    debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    noinline finishedAnimationListener: () -> Unit = null,
    crossinline content: MotionLayoutScope.() -> Unit
): Unit

Layout that takes a MotionScene and animates by providing a constraintSetName to animate to.

During recomposition, MotionLayout will interpolate from whichever ConstraintSet it is currently in, to constraintSetName.

Typically the first value of constraintSetName should match the start ConstraintSet in the default transition, or be null.

Animation is run by animationSpec, and will only start another animation once any other ones are finished. Use finishedAnimationListener to know when a transition has stopped.

MotionLayout

@Composable inline fun MotionLayout(
    start: ConstraintSet,
    end: ConstraintSet,
    transition: Transition? = null,
    progress: Float,
    debug: EnumSet<MotionLayoutDebugFlags> = EnumSet.of(MotionLayoutDebugFlags.NONE),
    informationReceiver: LayoutInformationReceiver? = null,
    modifier: Modifier = Modifier,
    optimizationLevel: Int = Optimizer.OPTIMIZATION_STANDARD,
    crossinline content: MotionLayoutScope.() -> Unit
): Unit

MotionScene

@Composable fun MotionScene(content: String): MotionScene

Parses the given JSON5 into a MotionScene.

See the official Github Wiki to learn the syntax.

Transition

@Composable fun Transition(content: String): Transition?

Parses the given JSON5 into a Transition.

See the official Github Wiki to learn the syntax.

Top-level properties

DesignInfoDataKey

val DesignInfoDataKey: SemanticsPropertyKey<DesignInfoProvider>

SemanticsPropertyKey to test DesignInfoProvider

Extension functions

atLeast

fun Dimension.Coercible.atLeast(dp: Dp): Dimension.MaxCoercible

Sets the lower bound of the current Dimension to a fixed dp value.

atLeast

fun Dimension.MinCoercible.atLeast(dp: Dp): Dimension

Sets the lower bound of the current Dimension to a fixed dp value.

atLeastWrapContent

fun Dimension.MinCoercible.atLeastWrapContent(dp: Dp): Dimension

Deprecated: Unintended method name, use atLeast(dp) instead. ["androidx.constraintlayout.compose.atLeast"]. Replace with: "this.atLeast(dp)".

Sets the lower bound of the current Dimension to a fixed dp value.

atMost

fun Dimension.Coercible.atMost(dp: Dp): Dimension.MinCoercible

Sets the upper bound of the current Dimension to a fixed dp value.

atMost

fun Dimension.MaxCoercible.atMost(dp: Dp): Dimension

Sets the upper bound of the current Dimension to a fixed dp value.

layoutId

fun Modifier.layoutId(
    layoutId: String,
    tag: String
): Modifier

Extension properties

atLeastWrapContent

val Dimension.Coercible.atLeastWrapContent: Dimension.MaxCoercible

Sets the lower bound of the current Dimension to be the wrap content size of the child.

atLeastWrapContent

val Dimension.MinCoercible.atLeastWrapContent: Dimension

Sets the lower bound of the current Dimension to be the wrap content size of the child.

atMostWrapContent

val Dimension.Coercible.atMostWrapContent: Dimension.MinCoercible

Sets the upper bound of the current Dimension to be the wrap content size of the child.

atMostWrapContent

val Dimension.MaxCoercible.atMostWrapContent: Dimension

Sets the upper bound of the current Dimension to be the Wrap size of the child.

constraintLayoutId

val Measurable.constraintLayoutId: Any?

constraintLayoutTag

val Measurable.constraintLayoutTag: Any?