# SubcomposeMeasureScope

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/layout/SubcomposeLayout.kt+class:androidx.compose.ui.layout.SubcomposeMeasureScope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface SubcomposeMeasureScope : MeasureScope
  ```

*** ** * ** ***

The receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeLayout.composable#SubcomposeLayout(androidx.compose.ui.Modifier,kotlin.Function2)`'s measure lambda which adds ability to dynamically subcompose a content during the measuring on top of the features provided by `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope`.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Measurable>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)(slotId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Performs subcomposition of the provided `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)` with given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)`. | Cmn |

| ### Inherited functions |
|---|
| From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) |---|---|---| | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).roundToPx()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).roundToPx()()` Convert Sp to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toDp()()` Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toDp()()` Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Dp | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.geometry.Size).toDpSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize`. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).toPx()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to pixels. | Cmn | | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).toPx()()` Convert Sp to pixels. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpRect).toRect()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpSize).toSize()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toSp()()` Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to Sp. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toSp()()` Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Sp | Cmn | |
| From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) |---|---|---| | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.TextUnit).toDp()()` Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn | | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.Dp).toSp()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp. | Cmn | |
| From [androidx.compose.ui.layout.MeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope) |---|---|---| | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureResult` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope#layout(kotlin.Int,kotlin.Int,kotlin.collections.Map,kotlin.Function1)( width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, alignmentLines: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/AlignmentLine, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, placementBlock: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureResult` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope#layout(kotlin.Int,kotlin.Int,kotlin.collections.Map,kotlin.Function1,kotlin.Function1)( width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, alignmentLines: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/AlignmentLine, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, rulers: (https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RulerScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, placementBlock: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. | Cmn | | `open https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureResult` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope#layout(kotlin.Int,kotlin.Int,kotlin.Function1,kotlin.Function2,kotlin.collections.Map,kotlin.Function1)( width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, isRulerProvided: (https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Ruler) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, rulerProvider: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RulerScope.(https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Ruler) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, alignmentLines: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/AlignmentLine, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, placementBlock: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` 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](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#density()` The logical density of the display. | Cmn | |
| From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) |---|---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#fontScale()` Current user preference for the scaling factor for fonts. | Cmn | |
| From [androidx.compose.ui.layout.IntrinsicMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope) |---|---|---| | `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope#isLookingAhead()` This indicates whether the ongoing measurement is for lookahead pass. | Cmn | | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope#layoutDirection()` The `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection` of the `Layout` or `LayoutModifier` using the measure scope to measure their children. | Cmn | |

## Public functions

### subcompose

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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

Performs subcomposition of the provided `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)` with given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)`.

| Parameters |
|---|---|
| `slotId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | 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: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | the composable content which defines the slot. It could emit multiple layouts, in this case the returned list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Measurable`s will have multiple elements. **Note:** When a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeLayout.composable#SubcomposeLayout(androidx.compose.ui.Modifier,kotlin.Function2)` is in a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/LookaheadScope`, the subcomposition only happens during the lookahead pass. In the post-lookahead/main pass, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)` will return the list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Measurable`s that were subcomposed during the lookahead pass. If the structure of the subtree emitted from `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope#subcompose(kotlin.Any,kotlin.Function0)` is dependent on incoming constraints, consider using constraints received from the lookahead pass for both passes. |