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.

Summary

Public functions

List<Measurable>
subcompose(slotId: Any?, content: @Composable () -> Unit)

Performs subcomposition of the provided content with given slotId.

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

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
From androidx.compose.ui.unit.FontScaling
open Dp

Convert Sp to Dp.

Cmn
open TextUnit

Convert Dp to Sp.

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

subcompose

fun subcompose(slotId: Any?, content: @Composable () -> Unit): List<Measurable>

Performs subcomposition of the provided content with given slotId.

Parameters
slotId: Any?

unique id which represents the slot we are composing into. If you have fixed amount or slots you can use enums as slot ids, or if you have a list of items maybe an index in the list or some other unique key can work. To be able to correctly match the content between remeasures you should provide the object which is equals to the one you used during the previous measuring.

content: @Composable () -> Unit

the composable content which defines the slot. It could emit multiple layouts, in this case the returned list of Measurables will have multiple elements. Note: When a SubcomposeLayout is in a LookaheadScope, the subcomposition only happens during the lookahead pass. In the post-lookahead/main pass, subcompose will return the list of Measurables that were subcomposed during the lookahead pass. If the structure of the subtree emitted from content is dependent on incoming constraints, consider using constraints received from the lookahead pass for both passes.