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

Placeable

abstract class Placeable : Measured
kotlin.Any
   ↳ androidx.compose.ui.layout.Placeable

A Placeable corresponds to a child layout that can be positioned by its parent layout. Most Placeables are the result of a Measurable.measure call.

A Placeable should never be stored between measure calls.

Summary

Nested classes
abstract

Receiver scope that permits explicit placement of a Placeable.

Public constructors

A Placeable corresponds to a child layout that can be positioned by its parent layout.

Protected methods
abstract Unit
placeAt(position: IntOffset, zIndex: Float, layerBlock: GraphicsLayerScope.() -> Unit)

Positions the Placeable at position in its parent's coordinate system.

Inherited functions
Properties
IntOffset

The offset to be added to an apparent position assigned to this Placeable to make it real.

Int

The height, in pixels, of the measured layout, as seen by the parent.

open Int

The measured height of the layout.

IntSize

The measured size of this Placeable.

open Int

The measured width of the layout.

Constraints

The constraints used for the measurement made to obtain this Placeable.

Int

The width, in pixels, of the measured layout, as seen by the parent.

Public constructors

<init>

Placeable()

A Placeable corresponds to a child layout that can be positioned by its parent layout. Most Placeables are the result of a Measurable.measure call.

A Placeable should never be stored between measure calls.

Protected methods

placeAt

protected abstract fun placeAt(
    position: IntOffset,
    zIndex: Float,
    layerBlock: GraphicsLayerScope.() -> Unit
): Unit

Positions the Placeable at position in its parent's coordinate system.

Parameters
zIndex: Float controls the drawing order for the Placeable. A Placeable with larger zIndex will be drawn on top of all the children with smaller zIndex. When children have the same zIndex the order in which the items were placed is used.
layerBlock: GraphicsLayerScope.() -> Unit when non-null this Placeable should be placed with an introduced graphic layer. You can configure any layer property available on GraphicsLayerScope via this block. Also if the Placeable will be placed with a new position next time only the graphic layer will be moved without requiring to redrawn the Placeable content.

Properties

apparentToRealOffset

protected val apparentToRealOffset: IntOffset

The offset to be added to an apparent position assigned to this Placeable to make it real. The real layout will be centered on the space assigned by the parent, which computed the child's position only seeing its apparent size.

height

var height: Int

The height, in pixels, of the measured layout, as seen by the parent. This will usually coincide with the measured height of the layout (aka the height value passed into MeasureScope.layout), but can be different if the layout does not respect its incoming constraints: in these cases the height will be coerced inside the min and max height constraints - to access the actual height that the layout measured itself to, use measuredHeight.

measuredHeight

open val measuredHeight: Int

The measured height of the layout. This might not respect the measurement constraints.

measuredSize

protected var measuredSize: IntSize

The measured size of this Placeable. This might not respect measurementConstraints.

measuredWidth

open val measuredWidth: Int

The measured width of the layout. This might not respect the measurement constraints.

measurementConstraints

protected var measurementConstraints: Constraints

The constraints used for the measurement made to obtain this Placeable.

width

var width: Int

The width, in pixels, of the measured layout, as seen by the parent. This will usually coincide with the measured width of the layout (aka the width value passed into MeasureScope.layout), but can be different if the layout does not respect its incoming constraints: in these cases the width will be coerced inside the min and max width constraints - to access the actual width that the layout measured itself to, use measuredWidth.