placeWithLayer

open fun Placeable.placeWithLayer(x: Int, y: Int, zIndex: Float = 0.0f, layerBlock: PlacementLayerScope.() -> Unit = DefaultLayerBlock)

Places the child at x from the left edge, whatever the orientation, with a layer whose properties layerBlock sets, as androidx's placeWithLayer does. Placing the child without a layer on a later pass removes the layer.

A MeasurePolicy's layer wraps the child's whole decoration, outside every step of its own modifier, and covers the extent the child measured to. A LayoutModifierNode's layer paints in the place of the node's decorator, at the node's position in the modifier: a decoration declared before the node paints outside the layer, and one declared after it paints inside. Placing with a layer fails while the node holds a decorator, and where the component placed is not a Decoratable. A placement that only replays where the children go, such as MeasureResult.placeChildren or an alignment-line query, places the child without a layer.

A state read in layerBlock repaints the component without measuring it again; where the paint outsets it takes resize a Foundation container, that container places its children again. Placing with a different block instance repaints the component; pass the same instance to avoid that.

Parameters

x

where the child's left edge lands, from the container's inner left edge

y

where the child's top edge lands, from the container's inner top edge

zIndex

the child's place in its container's paint and hit-testing order; see place.

layerBlock

sets the layer's properties; a layer at its defaults when omitted