# IntrinsicMeasureScope

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/IntrinsicMeasureScope.kt+class:androidx.compose.ui.layout.IntrinsicMeasureScope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface IntrinsicMeasureScope : Density
  ```
Known direct subclasses [ApproachIntrinsicMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachIntrinsicMeasureScope), [MeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachIntrinsicMeasureScope` | The receiver scope of a layout's intrinsic approach measurements lambdas. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope` | The receiver scope of a layout's measure lambda. |

Known indirect subclasses [ApproachMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope), [LazyLayoutMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutMeasureScope), [SubcomposeMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope` provides access to lookahead results to allow `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachLayoutModifierNode` to leverage lookahead results to define how measurements and placements approach their destination. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutMeasureScope` | The receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayout.composable#LazyLayout(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.layout.LazyLayoutPrefetchState,androidx.compose.foundation.lazy.layout.LazyLayoutMeasurePolicy)`'s measure lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope` | 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`. |

*** ** * ** ***

The receiver scope of a layout's intrinsic measurements lambdas.

## Summary

| ### Public properties |
|---|---|---|
| `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 |

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

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

## Public properties

### isLookingAhead

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

```
open val isLookingAhead: Boolean
```

This indicates whether the ongoing measurement is for lookahead pass. `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope` implementations, especially `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope` implementations should override this flag to reflect whether the measurement is intended for lookahead pass.

```kotlin
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector2D
import androidx.compose.animation.core.VectorConverter
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.layout.LookaheadScope
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.IntSize

var sizeAnim by remember { mutableStateOf<Animatable<IntSize, AnimationVector2D>?>(null) }
var lookaheadSize by remember { mutableStateOf<IntSize?>(null) }
val coroutineScope = rememberCoroutineScope()
LookaheadScope {
    // The Box is in a LookaheadScope. This means there will be a lookahead measure pass
    // before the main measure pass.
    // Here we are creating something similar to the `animateContentSize` modifier.
    Box(
        Modifier.clipToBounds().layout { measurable, constraints ->
            val placeable = measurable.measure(constraints)

            val measuredSize = IntSize(placeable.width, placeable.height)
            val (width, height) =
                if (isLookingAhead) {
                    // Record lookahead size if we are in lookahead pass. This lookahead size
                    // will be used for size animation, such that the main measure pass will
                    // gradually change size until it reaches the lookahead size.
                    lookaheadSize = measuredSize
                    measuredSize
                } else {
                    // Since we are in an explicit lookaheadScope, we know the lookahead pass
                    // is guaranteed to happen, therefore the lookahead size that we recorded is
                    // not null.
                    val target = requireNotNull(lookaheadSize)
                    val anim =
                        sizeAnim?.also { coroutineScope.launch { it.animateTo(target) } }
                            ?: Animatable(target, IntSize.VectorConverter)
                    sizeAnim = anim
                    // By returning the animated size only during main pass, we are allowing
                    // lookahead pass to see the future layout past the animation.
                    anim.value
                }

            layout(width, height) { placeable.place(0, 0) }
        }
    ) {
        // Some content that changes size
    }
}
```

### layoutDirection

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

```
val layoutDirection: 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.