Android 12 Developer Preview is here! Try it out, and give us your feedback!

LayoutCoordinates

interface LayoutCoordinates
androidx.compose.ui.layout.LayoutCoordinates

A holder of the measured bounds for the layout (MeasureBox).

Summary

Public methods
abstract operator Int
get(alignmentLine: AlignmentLine)

Returns the position in pixels of an alignment line, or AlignmentLine.Unspecified if the line is not provided.

abstract Rect
localBoundingBoxOf(sourceCoordinates: LayoutCoordinates, clipBounds: Boolean = true)

Returns the bounding box of sourceCoordinates in the local coordinates.

abstract Offset
localPositionOf(sourceCoordinates: LayoutCoordinates, relativeToSource: Offset)

Converts an relativeToSource in sourceCoordinates space into local coordinates.

abstract Offset
localToRoot(relativeToLocal: Offset)

Converts a local position within this layout into an offset from the root composable.

abstract Offset
localToWindow(relativeToLocal: Offset)

Converts relativeToLocal position within this layout into an Offset relative to the window's origin.

abstract Offset
windowToLocal(relativeToWindow: Offset)

Converts relativeToWindow relative to the window's origin into an Offset relative to this layout.

Extension functions
From androidx.compose.ui.layout
Rect

Returns the bounding box of the child in the parent's content area, including any clipping done with respect to the parent.

Rect

The boundaries of this layout inside the root composable.

Rect

The boundaries of this layout relative to the window's origin.

Offset

Returns the position of the top-left in the parent's content area or (0, 0) for the root.

Offset

The position of this layout inside the root composable.

Offset

The position of this layout relative to the window.

Properties
abstract Boolean

Returns false if the corresponding layout was detached from the hierarchy.

abstract LayoutCoordinates?

The coordinates of the parent layout modifier or parent layout if there is no parent layout modifier, or null if there is no parent.

abstract LayoutCoordinates?

The coordinates of the parent layout.

abstract Set<AlignmentLine>

The alignment lines provided for this layout, not including inherited lines.

abstract IntSize

The size of this layout in the local coordinates space.

Public methods

get

abstract operator fun get(alignmentLine: AlignmentLine): Int

Returns the position in pixels of an alignment line, or AlignmentLine.Unspecified if the line is not provided.

localBoundingBoxOf

abstract fun localBoundingBoxOf(
    sourceCoordinates: LayoutCoordinates,
    clipBounds: Boolean = true
): Rect

Returns the bounding box of sourceCoordinates in the local coordinates. If clipBounds is true, any clipping that occurs between sourceCoordinates and this layout will affect the returned bounds, and can even result in an empty rectangle if clipped regions do not overlap. If clipBounds is false, the bounding box of sourceCoordinates will be converted to local coordinates irrespective of any clipping applied between the layouts.

When rotation or scaling is applied, the bounding box of the rotated or scaled value will be computed in the local coordinates. For example, if a 40 pixels x 20 pixel layout is rotated 90 degrees, the bounding box will be 20 pixels x 40 pixels in its parent's coordinates.

localPositionOf

abstract fun localPositionOf(
    sourceCoordinates: LayoutCoordinates,
    relativeToSource: Offset
): Offset

Converts an relativeToSource in sourceCoordinates space into local coordinates. sourceCoordinates may be any LayoutCoordinates that belong to the same compose layout hierarchy.

localToRoot

abstract fun localToRoot(relativeToLocal: Offset): Offset

Converts a local position within this layout into an offset from the root composable.

localToWindow

abstract fun localToWindow(relativeToLocal: