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

Placeable

public abstract class Placeable implements Measured


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 types

public abstract class Placeable.PlacementScope

Receiver scope that permits explicit placement of a Placeable.

Public constructors

Public methods

final int

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

int

The measured height of the layout.

int

The measured width of the layout.

final int

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

Protected methods

final @NonNull IntOffset

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

final @NonNull IntSize

The measured size of this Placeable.

final @NonNull Constraints

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

abstract void
placeAt(
    @NonNull IntOffset position,
    float zIndex,
    @ExtensionFunctionType Function1<@NonNull GraphicsLayerScopeUnit> layerBlock
)

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

final void

The measured size of this Placeable.

final void

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

Inherited methods

From androidx.compose.ui.layout.Measured
abstract int
get(@NonNull AlignmentLine alignmentLine)

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

Object

Data provided by the ParentDataModifier applied to the layout.

Public constructors

Placeable

public Placeable()

Public methods

getHeight

public final int getHeight()

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.

getMeasuredHeight

public int getMeasuredHeight()

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

getMeasuredWidth

public int getMeasuredWidth()

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

getWidth

public final int getWidth()

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.

Protected methods

getApparentToRealOffset

protected final @NonNull IntOffset getApparentToRealOffset()

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.

getMeasuredSize

protected final @NonNull IntSize getMeasuredSize()

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

getMeasurementConstraints

protected final @NonNull Constraints getMeasurementConstraints()

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

placeAt

protected abstract void placeAt(
    @NonNull IntOffset position,
    float zIndex,
    @ExtensionFunctionType Function1<@NonNull GraphicsLayerScopeUnit> layerBlock
)

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

Parameters
float zIndex

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.

@ExtensionFunctionType Function1<@NonNull GraphicsLayerScopeUnit> layerBlock

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.

setMeasuredSize

protected final void setMeasuredSize(@NonNull IntSize measuredSize)

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

setMeasurementConstraints

protected final void setMeasurementConstraints(@NonNull Constraints measurementConstraints)

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