androidx.compose.ui.layout
PlacementScope
Abstract class · from org.jetbrains.compose.ui:ui:1.12.2
No hand-written docs yet.
Receiver scope that permits explicit placement of a Placeable.
abstract class PlacementScope : Density
Is a
Properties
coordinates
val coordinates: LayoutCoordinates?
The LayoutCoordinates of this layout, if known or null if the layout hasn't been placed yet. coordinates will be null when determining alignment lines, preventing alignment lines from depending on absolute coordinates.
Functions
current
fun Ruler.current(defaultValue: Float): Float
Returns the value for this Ruler or defaultValue if it wasn't provided``RulerScope.provides. Ruler values are unavailable while calculating AlignmentLines.
placeRelative
fun Placeable.placeRelative(
position: IntOffset,
zIndex: Float = 0f,
)
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.
fun Placeable.placeRelative(
x: Int,
y: Int,
zIndex: Float = 0f,
)
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.
place
fun Placeable.place(
x: Int,
y: Int,
zIndex: Float = 0f,
)
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.
fun Placeable.place(
position: IntOffset,
zIndex: Float = 0f,
)
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.
placeRelativeWithLayer
fun Placeable.placeRelativeWithLayer(
position: IntOffset,
zIndex: Float = 0f,
layerBlock: GraphicsLayerScope.() -> Unit = DefaultLayerBlock,
)
Place a Placeable at position in its parent's coordinate system with an introduced graphic layer. 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.
fun Placeable.placeRelativeWithLayer(
x: Int,
y: Int,
zIndex: Float = 0f,
layerBlock: GraphicsLayerScope.() -> Unit = DefaultLayerBlock,
)
Place a Placeable at x, y in its parent's coordinate system with an introduced graphic layer. 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.
placeWithLayer
fun Placeable.placeWithLayer(
x: Int,
y: Int,
zIndex: Float = 0f,
layerBlock: GraphicsLayerScope.() -> Unit = DefaultLayerBlock,
)
Place a Placeable at x, y in its parent's coordinate system with an introduced graphic layer. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.
fun Placeable.placeWithLayer(
position: IntOffset,
zIndex: Float = 0f,
layerBlock: GraphicsLayerScope.() -> Unit = DefaultLayerBlock,
)
Place a Placeable at position in its parent's coordinate system with an introduced graphic layer. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.
fun Placeable.placeWithLayer(
x: Int,
y: Int,
layer: GraphicsLayer,
zIndex: Float = 0f,
)
Place a Placeable at x, y in its parent's coordinate system with an introduced graphic layer. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.
fun Placeable.placeWithLayer(
position: IntOffset,
layer: GraphicsLayer,
zIndex: Float = 0f,
)
Place a Placeable at position in its parent's coordinate system with an introduced graphic layer. Unlike placeRelative, the given position will not implicitly react in RTL layout direction contexts.
fun Placeable.placeRelativeWithLayer(
x: Int,
y: Int,
layer: GraphicsLayer,
zIndex: Float = 0f,
)
Place a Placeable at x, y in its parent's coordinate system with an introduced graphic layer. 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.
fun Placeable.placeRelativeWithLayer(
position: IntOffset,
layer: GraphicsLayer,
zIndex: Float = 0f,
)
Place a Placeable at position in its parent's coordinate system with an introduced graphic layer. 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.
withMotionFrameOfReferencePlacement
fun withMotionFrameOfReferencePlacement(block: PlacementScope.() -> Unit)
Placement done under block, will have their Placeable placed on the same frame of reference as the current layout.
Library docs
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.