Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.foundation.layout

Interfaces

BoxScope

A BoxScope provides a scope for the children of a Box.

ColumnScope

Scope for the children of Column.

ConstraintSet

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

Dimension

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

RowScope

Scope for the children of Row.

Classes

ChainStyle

The style of a horizontal or vertical chain.

ConstrainedLayoutReference

Represents a layout within a ConstraintLayout.

ConstrainScope

Scope used by Modifier.constrainAs.

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.

PaddingValues

Describes a padding to be applied along the edges inside a box.

State

The state of the ConstraintLayout solver.

Type-aliases

FlowMainAxisAlignment

InnerPadding

StackScope

Annotations

ExperimentalLayout

InternalLayoutApi

LayoutScopeMarker

Enums

FlowCrossAxisAlignment

Used to specify the alignment of a layout's children, in cross axis direction.

IntrinsicSize

Intrinsic size used in preferredWidth or preferredHeight which can refer to width or height.

MainAxisAlignment

Used to specify the alignment of a layout's children, in main axis direction.

SizeMode

Used to specify how a layout chooses its own size when multiple behaviors are possible.

Top-level functions summary

Unit
Box(modifier: Modifier = Modifier, alignment: Alignment = Alignment.TopStart, crossinline children: BoxScope.() -> Unit)

A layout composable that positions its children relative to its edges.

Unit
Box(modifier: Modifier)

A convenience box with no content that can participate in layout, drawing, pointer input due to the modifier applied to it.

Unit
Column(modifier: Modifier = Modifier, verticalArrangement: Arrangement.Vertical = Arrangement.Top, horizontalAlignment: Alignment.Horizontal = Alignment.Start, children: ColumnScope.() -> Unit)

A layout composable that places its children in a vertical sequence.

Unit
ConstraintLayout(modifier: Modifier = Modifier, children: ConstraintLayoutScope.() -> Unit)

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

Unit
ConstraintLayout(constraintSet: ConstraintSet, modifier: Modifier = Modifier, children: () -> Unit)

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

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

Creates a ConstraintSet.

Unit
FlowColumn(mainAxisSize: SizeMode = SizeMode.Wrap, mainAxisAlignment: FlowMainAxisAlignment = FlowMainAxisAlignment.Start, mainAxisSpacing: Dp = 0.dp, crossAxisAlignment: FlowCrossAxisAlignment = FlowCrossAxisAlignment.Start, crossAxisSpacing: Dp = 0.dp, lastLineMainAxisAlignment: FlowMainAxisAlignment = mainAxisAlignment, children: () -> Unit)

A composable that places its children in a vertical flow.

Unit
FlowRow(mainAxisSize: SizeMode = SizeMode.Wrap, mainAxisAlignment: FlowMainAxisAlignment = FlowMainAxisAlignment.Start, mainAxisSpacing: Dp = 0.dp, crossAxisAlignment: FlowCrossAxisAlignment = FlowCrossAxisAlignment.Start, crossAxisSpacing: Dp = 0.dp, lastLineMainAxisAlignment: FlowMainAxisAlignment = mainAxisAlignment, children: () -> Unit)

A composable that places its children in a horizontal flow.

Unit
Row(modifier: Modifier = Modifier, horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, verticalAlignment: Alignment.Vertical = Alignment.Top, children: RowScope.() -> Unit)

A layout composable that places its children in a horizontal sequence.

Unit
Spacer(modifier: Modifier)

Component that represents an empty space layout, whose size can be defined using the LayoutWidth, LayoutHeight and LayoutSize modifiers.

Unit
Stack(modifier: Modifier = Modifier, alignment: Alignment = Alignment.TopStart, children: BoxScope.() -> Unit)

Extension functions summary

For Modifier
Modifier
Modifier.absoluteOffset(x: Dp = 0.dp, y: Dp = 0.dp)

Offset the content by (x dp, y dp).

Modifier
Modifier.absoluteOffsetPx(x: State<Float> = mutableStateOf(0f), y: State<Float> = mutableStateOf(0f))

Offset the content by (x px, y px).

Modifier
Modifier.absolutePadding(left: Dp = 0.dp, top: Dp = 0.dp, right: Dp = 0.dp, bottom: Dp = 0.dp)

Apply additional space along each edge of the content in Dp: left, top, right and bottom.

Modifier
Modifier.aspectRatio(@FloatRange(0.0, 3.4E38, false) ratio: Float, matchHeightConstraintsFirst: Boolean = false)

Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: Constraints.maxWidth, Constraints.maxHeight, Constraints.minWidth, Constraints.minHeight if matchHeightConstraintsFirst is false (which is the default), or Constraints.maxHeight, Constraints.maxWidth, Constraints.minHeight, Constraints.minWidth if matchHeightConstraintsFirst is true.

Modifier
Modifier.defaultMinSizeConstraints(minWidth: Dp = Dp.Unspecified, minHeight: Dp = Dp.Unspecified)

Constrain the size of the wrapped layout only when it would be otherwise unconstrained: the minWidth and minHeight constraints are only applied when the incoming corresponding constraint is 0.

Modifier
Modifier.fillMaxHeight(@FloatRange(0.0, 1.0) fraction: Float = 1f)

Have the content fill (possibly only partially) the Constraints.maxHeight of the incoming measurement constraints, by setting the minimum height and the maximum height to be equal to the maximum height multiplied by fraction.

Modifier
Modifier.fillMaxSize(@FloatRange(0.0, 1.0) fraction: Float = 1f)

Have the content fill (possibly only partially) the Constraints.maxWidth and Constraints.maxHeight of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction, as well as the minimum height and the maximum height to be equal to the maximum height multiplied by fraction.

Modifier
Modifier.fillMaxWidth(@FloatRange(0.0, 1.0) fraction: Float = 1f)

Have the content fill (possibly only partially) the Constraints.maxWidth of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction.

Modifier
Modifier.height(height: Dp)

Declare the height of the content to be exactly heightdp.

Modifier
Modifier.heightIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified)

Constrain the height of the content to be between mindp and maxdp.

Modifier
Modifier.offset(x: Dp = 0.dp, y: Dp = 0.dp)

Offset the content by (x dp, y dp).

Modifier
Modifier.offsetPx(x: State<Float> = mutableStateOf(0f), y: State<Float> = mutableStateOf(0f))

Offset the content by (x px, y px).

Modifier
Modifier.padding(start: Dp = 0.dp, top: Dp = 0.dp, end: Dp = 0.dp, bottom: Dp = 0.dp)

Apply additional space along each edge of the content in Dp: start, top, end and bottom.

Modifier
Modifier.padding(horizontal: Dp = 0.dp, vertical: Dp = 0.dp)

Apply horizontal dp space along the left and right edges of the content, and vertical dp space along the top and bottom edges.

Modifier

Apply all dp of additional space along each edge of the content, left, top, right and bottom.

Modifier

Apply PaddingValues to the component as additional space along each edge of the content's left, top, right and bottom.

Modifier
Modifier.paddingFrom(alignmentLine: AlignmentLine, before: Dp = Dp.Unspecified, after: Dp = Dp.Unspecified)

A Modifier that can add padding to position the content according to specified distances from its bounds to an alignment line.

Modifier
Modifier.paddingFrom(alignmentLine: AlignmentLine, before: TextUnit = TextUnit.Inherit, after: TextUnit = TextUnit.Inherit)

A Modifier that can add padding to position the content according to specified distances from its bounds to an alignment line.

Modifier
Modifier.paddingFromBaseline(top: Dp = Dp.Unspecified, bottom: Dp = Dp.Unspecified)

A Modifier that positions the content in a layout such that the distance from the top of the layout to the baseline of the first line of text in the content is top, and the distance from the baseline of the last line of text in the content to the bottom of the layout is bottom.

Modifier
Modifier.paddingFromBaseline(top: TextUnit = TextUnit.Inherit, bottom: TextUnit = TextUnit.Inherit)

A Modifier that positions the content in a layout such that the distance from the top of the layout to the baseline of the first line of text in the content is top, and the distance from the baseline of the last line of text in the content to the bottom of the layout is bottom.

Modifier

Declare the preferred height of the content to be the same as the min or max intrinsic height of the content.

Modifier

Declare the preferred height of the content to be exactly heightdp.

Modifier
Modifier.preferredHeightIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified)

Constrain the height of the content to be between mindp and maxdp as permitted by the incoming measurement Constraints.

Modifier

Declare the preferred size of the content to be exactly sizedp square.

Modifier
Modifier.preferredSize(width: Dp, height: Dp)

Declare the preferred size of the content to be exactly widthdp by heightdp.

Modifier
Modifier.preferredSizeIn(minWidth: Dp = Dp.Unspecified, minHeight: Dp = Dp.Unspecified, maxWidth: Dp = Dp.Unspecified, maxHeight: Dp = Dp.Unspecified)

Constrain the width of the content to be between minWidthdp and maxWidthdp and the height of the content to be between minHeight and maxHeight as permitted by the incoming measurement Constraints.

Modifier

Declare the preferred width of the content to be the same as the min or max intrinsic width of the content.

Modifier

Declare the preferred width of the content to be exactly widthdp.

Modifier
Modifier.preferredWidthIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified)

Constrain the width of the content to be between mindp and maxdp as permitted by the incoming measurement Constraints.

Modifier