{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

LayoutCoordinates

public interface LayoutCoordinates

Known direct subclasses
LookaheadLayoutCoordinates

This interface is deprecated. LookaheadLayoutCoordinates class has been removed. localLookaheadPositionOfcan be achieved in LookaheadScope using LayoutCoordinates.localLookaheadPositionOf(LayoutCoordinates) function.


A holder of the measured bounds for the Layout.

Summary

Public methods

abstract int
get(@NonNull AlignmentLine alignmentLine)

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

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 @NonNull Set<@NonNull AlignmentLine>

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

abstract @NonNull IntSize

The size of this layout in the local coordinates space.

abstract boolean

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

abstract @NonNull Rect
localBoundingBoxOf(
    @NonNull LayoutCoordinates sourceCoordinates,
    boolean clipBounds
)

Returns the bounding box of sourceCoordinates in the local coordinates.

abstract @NonNull Offset
localPositionOf(
    @NonNull LayoutCoordinates sourceCoordinates,
    @NonNull Offset relativeToSource
)

Converts an relativeToSource in sourceCoordinates space into local coordinates.

abstract @NonNull Offset
localToRoot(@NonNull Offset relativeToLocal)

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

abstract @NonNull Offset
localToWindow(@NonNull Offset relativeToLocal)

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

default void
transformFrom(
    @NonNull LayoutCoordinates sourceCoordinates,
    @NonNull Matrix matrix
)

Modifies matrix to be a transform to convert a coordinate in sourceCoordinates to a coordinate in this LayoutCoordinates.

abstract @NonNull Offset
windowToLocal(@NonNull Offset relativeToWindow)

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

Extension functions

default final @NonNull Rect

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

default final @NonNull Rect

The boundaries of this layout inside the root composable.

default final @NonNull Rect

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

default final @NonNull LayoutCoordinates

Walks up the LayoutCoordinates hierarchy to find the LayoutCoordinates whose LayoutCoordinates.parentCoordinates is null and returns it.

default final @NonNull Offset

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

default final @NonNull Offset

The position of this layout inside the root composable.

default final @NonNull Offset

The position of this layout relative to the window.

Public methods

get

abstract int get(@NonNull AlignmentLine alignmentLine)

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

getParentCoordinates

abstract LayoutCoordinates getParentCoordinates()

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

getParentLayoutCoordinates

abstract LayoutCoordinates getParentLayoutCoordinates()

The coordinates of the parent layout. Null if there is no parent.

getProvidedAlignmentLines

abstract @NonNull Set<@NonNull AlignmentLinegetProvidedAlignmentLines()

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

getSize

abstract @NonNull IntSize getSize()

The size of this layout in the local coordinates space.

isAttached

abstract boolean isAttached()

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

localBoundingBoxOf

abstract @NonNull Rect localBoundingBoxOf(
    @NonNull LayoutCoordinates sourceCoordinates,
    boolean clipBounds
)

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 @NonNull Offset localPositionOf(
    @NonNull LayoutCoordinates sourceCoordinates,
    @NonNull Offset relativeToSource
)

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

localToRoot

abstract @NonNull Offset localToRoot(@NonNull Offset relativeToLocal)

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

localToWindow

abstract @NonNull Offset localToWindow(@NonNull Offset relativeToLocal)

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

transformFrom

default void transformFrom(
    @NonNull LayoutCoordinates sourceCoordinates,
    @NonNull Matrix matrix
)

Modifies matrix to be a transform to convert a coordinate in sourceCoordinates to a coordinate in this LayoutCoordinates.

windowToLocal

abstract @NonNull Offset windowToLocal(@NonNull Offset relativeToWindow)

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

Extension functions

LayoutCoordinatesKt.boundsInParent

default final @NonNull Rect LayoutCoordinatesKt.boundsInParent(@NonNull LayoutCoordinates receiver)

Returns the bounding box of the child in the parent's content area, including any clipping done with respect to the parent. For the root, the bounds is positioned at (0, 0) and sized to the size of the root.

LayoutCoordinatesKt.boundsInRoot

default final @NonNull Rect LayoutCoordinatesKt.boundsInRoot(@NonNull LayoutCoordinates receiver)

The boundaries of this layout inside the root composable.

LayoutCoordinatesKt.boundsInWindow

default final @NonNull Rect LayoutCoordinatesKt.boundsInWindow(@NonNull LayoutCoordinates receiver)

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

LayoutCoordinatesKt.findRootCoordinates

default final @NonNull LayoutCoordinates LayoutCoordinatesKt.findRootCoordinates(
    @NonNull LayoutCoordinates receiver
)

Walks up the LayoutCoordinates hierarchy to find the LayoutCoordinates whose LayoutCoordinates.parentCoordinates is null and returns it. If LayoutCoordinates.isAttached, this will have the size of the androidx.compose.ui.platform.ComposeView.

LayoutCoordinatesKt.positionInParent

default final @NonNull Offset LayoutCoordinatesKt.positionInParent(
    @NonNull LayoutCoordinates receiver
)

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

LayoutCoordinatesKt.positionInRoot

default final @NonNull Offset LayoutCoordinatesKt.positionInRoot(@NonNull LayoutCoordinates receiver)

The position of this layout inside the root composable.

LayoutCoordinatesKt.positionInWindow

default final @NonNull Offset LayoutCoordinatesKt.positionInWindow(
    @NonNull LayoutCoordinates receiver
)

The position of this layout relative to the window.