androidx.compose.ui.layout

AlignmentLine

Sealed class · from org.jetbrains.compose.ui:ui:1.12.2

No hand-written docs yet.

Defines an offset line that can be used by parent layouts to align and position their children. Text baselines are representative examples of AlignmentLines. For example, they can be used by Row, to align its children by baseline, or by paddingFrom to achieve a layout with a specific distance from the top to the baseline of the text content. AlignmentLines can be understood as an abstraction over text baselines.

sealed class AlignmentLine(
    merger: (Int, Int) -> Int,
)

Kinds of AlignmentLine

Anywhere a AlignmentLine is expected, you can pass any of these.

How to get one

Used by

Parameters that take a AlignmentLine.

Properties

Unspecified

const val Unspecified

Constant representing that an AlignmentLine has not been provided.

Library docs

Defines an offset line that can be used by parent layouts to align and position their children. Text baselines are representative examples of AlignmentLines. For example, they can be used by Row, to align its children by baseline, or by paddingFrom to achieve a layout with a specific distance from the top to the baseline of the text content. AlignmentLines can be understood as an abstraction over text baselines.

When a layout provides a value for a particular AlignmentLine, this can be read by the parents of the layout after measuring, using the Placeable.get operator on the corresponding Placeable instance. Based on the position of the AlignmentLine, the parents can then decide the positioning of the children.

Note that when a layout provides a value for an AlignmentLine, this will be automatically inherited by the layout's parent, which will offset the value by the position of the child within itself. This way, nested layout hierarchies are able to preserve the AlignmentLines defined for deeply nested children, making it possible for non-direct parents to use these for positioning and alignment. When a layout inherits multiple values for the same AlignmentLine from different children, the position of the line within the layout will be computed by merging the children values using the provided merger. If a layout provides a value for an AlignmentLine, this will always be the position of the line, regardless of the values provided by children for the same line.

AlignmentLines cannot be created directly, please create VerticalAlignmentLine or HorizontalAlignmentLine instances instead.