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

LazyLayoutMeasureScope

@ExperimentalFoundationApi
public sealed interface LazyLayoutMeasureScope extends MeasureScope


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

Main difference from the regular flow of writing any custom layout is that you have a new function measure which accepts item index and constraints, composes the item based and then measures all the layouts emitted in the item content block.

Summary

Public methods

abstract @NonNull List<@NonNull Placeable>
measure(int index, @NonNull Constraints constraints)

Subcompose and measure the item of lazy layout.

default @NonNull Dp
toDp(float receiver)

Convert a Float pixel value to a Dp

default @NonNull Dp
toDp(int receiver)

Convert an Int pixel value to Dp.

default @NonNull Dp
toDp(@NonNull TextUnit receiver)

Convert Sp to Dp.

default @NonNull DpSize
toDpSize(@NonNull Size receiver)

Convert a Size to a DpSize.

default @NonNull Size
toSize(@NonNull DpSize receiver)

Convert a DpSize to a Size.

default @NonNull TextUnit
toSp(@NonNull Dp receiver)

Convert Dp to Sp.

default @NonNull TextUnit
toSp(float receiver)

Convert a Float pixel value to a Sp

default @NonNull TextUnit
toSp(int receiver)

Convert an Int pixel value to Sp.

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 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.

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.

From androidx.compose.ui.layout.MeasureScope
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.

Public methods

measure

abstract @NonNull List<@NonNull Placeablemeasure(int index, @NonNull Constraints constraints)

Subcompose and measure the item of lazy layout.

Parameters
int index

the item index. Should be no larger that LazyLayoutItemProvider.itemCount.

@NonNull Constraints constraints

Constraints to measure the children emitted into an item content composable specified via LazyLayoutItemProvider.Item.

Returns
@NonNull List<@NonNull Placeable>

List of Placeables. Note that if you emitted multiple children into the item composable you will receive multiple placeables, each of them will be measured with the passed constraints.

toDp

default @NonNull Dp toDp(float receiver)

Convert a Float pixel value to a Dp

toDp

default @NonNull Dp toDp(int receiver)

Convert an Int pixel value to Dp.

toDp

default @NonNull Dp toDp(@NonNull TextUnit receiver)

Convert Sp to Dp.

Throws
kotlin.IllegalStateException

if TextUnit other than SP unit is specified.

toDpSize

default @NonNull DpSize toDpSize(@NonNull Size receiver)

Convert a Size to a DpSize.

toSize

default @NonNull Size toSize(@NonNull DpSize receiver)

Convert a DpSize to a Size.

toSp

default @NonNull TextUnit toSp(@NonNull Dp receiver)

Convert Dp to Sp. Sp is used for font size, etc.

toSp

default @NonNull TextUnit toSp(float receiver)

Convert a Float pixel value to a Sp

toSp

default @NonNull TextUnit toSp(int receiver)

Convert an Int pixel value to Sp.