LazyLayoutMeasureScope


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.

Note: this interface is a part of LazyLayout harness that allows for building custom lazy layouts. LazyLayout and all corresponding APIs are still under development and are subject to change.

Summary

Public functions

List<Placeable>
measure(index: Int, constraints: Constraints)

Subcompose and measure the item of lazy layout.

Cmn
open Dp

Convert Sp to Dp.

Cmn
open Dp

Convert an Int pixel value to Dp.

Cmn
open Dp

Convert a Float pixel value to a Dp

Cmn
open DpSize

Convert a Size to a DpSize.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert Dp to Sp.

Cmn

Inherited functions

From androidx.compose.ui.unit.Density
open Int

Convert Dp to Int by rounding

Cmn
open Int

Convert Sp to Int by rounding

Cmn
open Float

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
From androidx.compose.ui.layout.MeasureScope
open MeasureResult
layout(
    width: Int,
    height: Int,
    alignmentLines: Map<AlignmentLineInt>,
    placementBlock: Placeable.PlacementScope.() -> Unit
)

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

Cmn
open MeasureResult
layout(
    width: Int,
    height: Int,
    alignmentLines: Map<AlignmentLineInt>,
    rulers: (RulerScope.() -> Unit)?,
    placementBlock: Placeable.PlacementScope.() -> Unit
)

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

Cmn

Inherited properties

From androidx.compose.ui.unit.Density
Float

The logical density of the display.

Cmn
From androidx.compose.ui.unit.FontScaling
Float

Current user preference for the scaling factor for fonts.

Cmn
From androidx.compose.ui.layout.IntrinsicMeasureScope
open Boolean

This indicates whether the ongoing measurement is for lookahead pass.

Cmn
LayoutDirection

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

Cmn

Public functions

measure

fun measure(index: Int, constraints: Constraints): List<Placeable>

Subcompose and measure the item of lazy layout.

Parameters
index: Int

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

constraints: Constraints

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

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

open fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Throws
kotlin.IllegalStateException

if TextUnit other than SP unit is specified.

open fun Int.toDp(): Dp

Convert an Int pixel value to Dp.

open fun Float.toDp(): Dp

Convert a Float pixel value to a Dp

open fun Size.toDpSize(): DpSize

Convert a Size to a DpSize.

open fun DpSize.toSize(): Size

Convert a DpSize to a Size.

open fun Float.toSp(): TextUnit

Convert a Float pixel value to a Sp

open fun Int.toSp(): TextUnit

Convert an Int pixel value to Sp.

open fun Dp.toSp(): TextUnit

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