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

MeasureScope

public interface MeasureScope extends IntrinsicMeasureScope

Known direct subclasses
IntermediateMeasureScope

IntermediateMeasureScope provides access to lookahead results to allow intermediateLayout to leverage lookahead results to define intermediate measurements and placements to gradually converge with lookahead.

LazyLayoutMeasureScope

The receiver scope of a LazyLayout's measure lambda.

SubcomposeMeasureScope

The receiver scope of a SubcomposeLayout's measure lambda which adds ability to dynamically subcompose a content during the measuring on top of the features provided by MeasureScope.

Known indirect subclasses
SubcomposeIntermediateMeasureScope

SubcomposeIntermediateMeasureScope is the receiver scope for the intermediate measurer policy that gets invoked during the intermediate measure pass.


The receiver scope of a layout's measure lambda. The return value of the measure lambda is MeasureResult, which should be returned by layout

Summary

Public methods

default @NonNull MeasureResult
layout(
    int width,
    int height,
    @NonNull Map<@NonNull AlignmentLine, @NonNull Integer> alignmentLines,
    @ExtensionFunctionType @NonNull Function1<@NonNull Placeable.PlacementScopeUnit> placementBlock
)

Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic.

Inherited methods

From androidx.compose.ui.unit.Density
abstract float

The logical density of the display.

abstract float

Current user preference for the scaling factor for fonts.

default int

Convert Dp to Int by rounding

default int

Convert Sp to Int by rounding

default @NonNull Dp

Convert Sp to Dp.

default @NonNull Dp
orgKt.toDp(int receiver)

Convert an Int pixel value to Dp.

default @NonNull Dp
orgKt.toDp(float receiver)

Convert a Float pixel value to a Dp

default @NonNull DpSize

Convert a Size to a DpSize.

default float
orgKt.toPx(@NonNull Dp receiver)

Convert Dp to pixels.

default float

Convert Sp to pixels.

default @NonNull Rect

Convert a DpRect to a Rect.

default @NonNull Size

Convert a DpSize to a Size.

default @NonNull TextUnit
orgKt.toSp(@NonNull Dp receiver)

Convert Dp to Sp.

default @NonNull TextUnit
orgKt.toSp(int receiver)

Convert an Int pixel value to Sp.

default @NonNull TextUnit
orgKt.toSp(float receiver)

Convert a Float pixel value to a Sp

From androidx.compose.ui.layout.IntrinsicMeasureScope
abstract @NonNull LayoutDirection

The LayoutDirection of the Layout or LayoutModifier using the measure scope to measure their children.

default boolean

This indicates whether the ongoing measurement is for lookahead pass.

Public methods

layout

default @NonNull MeasureResult layout(
    int width,
    int height,
    @NonNull Map<@NonNull AlignmentLine, @NonNull Integer> alignmentLines,
    @ExtensionFunctionType @NonNull Function1<@NonNull Placeable.PlacementScopeUnit> placementBlock
)

Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. The placementBlock is a lambda used for positioning children. Placeable.placeAt should be called on children inside placementBlock. The alignmentLines can be used by the parent layouts to decide layout, and can be queried using the Placeable.get operator. Note that alignment lines will be inherited by parent layouts, such that indirect parents will be able to query them as well.

Parameters
int width

the measured width of the layout

int height

the measured height of the layout

@NonNull Map<@NonNull AlignmentLine, @NonNull Integer> alignmentLines

the alignment lines defined by the layout

@ExtensionFunctionType @NonNull Function1<@NonNull Placeable.PlacementScopeUnit> placementBlock

block defining the children positioning of the current layout