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

PlacementScope

abstract class PlacementScope
kotlin.Any
   ↳ androidx.compose.ui.Placeable.PlacementScope

Receiver scope that permits explicit placement of a Placeable.

While a Placeable may be placed at any time, this explicit receiver scope is used to discourage placement outside of MeasureScope.layout positioning blocks. This permits Compose UI to perform additional layout optimizations allowing repositioning a Placeable without remeasuring its original Measurable if factors contributing to its potential measurement have not changed. The scope also allows automatic mirroring of children positions in RTL layout direction contexts using the placeRelative methods available in the scope. If the automatic mirroring is not desired, place should be used instead.

Summary

Public constructors

Receiver scope that permits explicit placement of a Placeable.

Public methods
Unit
Placeable.place(position: Offset)

Place a Placeable at position in its parent's coordinate system.

Unit

Place a Placeable at x, y in its parent's coordinate system.

Unit

Place a Placeable at position in its parent's coordinate system.

Unit

Place a Placeable at position in its parent's coordinate system.

Unit

Place a Placeable at position in its parent's coordinate system.

Unit

Place a Placeable at x, y in its parent's coordinate system.

Properties
abstract LayoutDirection

Keeps the layout direction of the parent of the placeable that is being places using current PlacementScope.

abstract Int

Keeps the parent layout node's width to make the automatic mirroring of the position in RTL environment.

Public constructors

<init>

PlacementScope()

Receiver scope that permits explicit placement of a Placeable.

While a Placeable may be placed at any time, this explicit receiver scope is used to discourage placement outside of MeasureScope.layout positioning blocks. This permits Compose UI to perform additional layout optimizations allowing repositioning a Placeable without remeasuring its original Measurable if factors contributing to its potential measurement have not changed. The scope also allows automatic mirroring of children positions in RTL layout direction contexts using the placeRelative methods available in the scope. If the automatic mirroring is not desired, place should be used instead.

Public methods

place

fun Placeable.place(position: Offset): Unit

Place a Placeable at position in its parent's coordinate system. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.

place

fun Placeable.place(
    x: Int,
    y: Int
): Unit

Place a Placeable at x, y in its parent's coordinate system. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.

place

fun Placeable.place(position: IntOffset): Unit

Place a Placeable at position in its parent's coordinate system. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.

placeRelative

fun Placeable.placeRelative(position: IntOffset): Unit

Place a Placeable at position in its parent's coordinate system. If the layout direction is right-to-left, the given position will be horizontally mirrored so that the position of the Placeable implicitly reacts to RTL layout direction contexts. If this method is used outside the MeasureScope.layout positioning block, the automatic position mirroring will not happen and the Placeable will be placed at the given position, similar to the place method.

placeRelative

fun Placeable.placeRelative(position: Offset): Unit

Place a Placeable at position in its parent's coordinate system. If the layout direction is right-to-left, the given position will be horizontally mirrored so that the position of the Placeable implicitly reacts to RTL layout direction contexts. If this method is used outside the MeasureScope.layout positioning block, the automatic position mirroring will not happen and the Placeable will be placed at the given position, similar to the place method.

placeRelative

fun Placeable.placeRelative(
    x: Int,
    y: Int
): Unit

Place a Placeable at x, y in its parent's coordinate system. If the layout direction is right-to-left, the given position will be horizontally mirrored so that the position of the Placeable implicitly reacts to RTL layout direction contexts. If this method is used outside the MeasureScope.layout positioning block, the automatic position mirroring will not happen and the Placeable will be placed at the given position, similar to the place method.

Properties

parentLayoutDirection

abstract val parentLayoutDirection: LayoutDirection

Keeps the layout direction of the parent of the placeable that is being places using current PlacementScope. Used to support automatic position mirroring for convenient RTL support in custom layouts.

parentWidth

abstract val parentWidth: Int

Keeps the parent layout node's width to make the automatic mirroring of the position in RTL environment. If the value is zero, than the Placeable will be be placed to the original position (position will not be mirrored).