# WindowInsetsRulers

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

  ```
  sealed interface WindowInsetsRulers
  ```

*** ** * ** ***

Contains rulers used for window insets. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` values are available as well as values when the insets are `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()`.

Other animation properties can be retrieved with `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#getAnimation(androidx.compose.ui.layout.Placeable.PlacementScope)`.

## Summary

| ### Nested types |
|---|
| `object https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers.Companion` |

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#innermostOf(kotlin.Array)(vararg windowInsetsRulers: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers)` Merges the rulers in `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers.Companion#innermostOf(kotlin.Array)`, providing the innermost values from `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()`. | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#CaptionBar()` Rulers used for caption bar insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#DisplayCutout()` Rulers used for display cutout insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#Ime()` Rulers used for IME insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#MandatorySystemGestures()` Rulers used for mandatory system gestures insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#NavigationBars()` Rulers used for navigation bars insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SafeContent()` Rulers used for insets that are safe for any content. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SafeDrawing()` Rulers used for insets including system bars, IME, and the display cutout. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SafeGestures()` Rulers used for insets that include places where gestures could conflict. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#StatusBars()` Rulers used for status bars insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SystemBars()` Rulers used for system bars insets, including `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#StatusBars()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#NavigationBars()`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#CaptionBar()`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SystemGestures()` Rulers used for system gestures insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#TappableElement()` Rulers used for tappable elements insets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#Waterfall()` Rulers used for waterfall insets. | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsAnimation` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#getAnimation(androidx.compose.ui.layout.Placeable.PlacementScope)(scope: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope)` Additional properties related to animating this `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RectRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` The current values for the window insets RectRulers. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RectRulers` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()` The values for the insets when the insets are fully visible. | Cmn |

## Public companion functions

### innermostOf

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

```
fun innermostOf(vararg windowInsetsRulers: WindowInsetsRulers): WindowInsetsRulers
```

Merges the rulers in `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers.Companion#innermostOf(kotlin.Array)`, providing the innermost values from `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#getAnimation(androidx.compose.ui.layout.Placeable.PlacementScope)` will return values with only `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsAnimation#isVisible()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsAnimation#isAnimating()` set to meaningful values.

## Public companion properties

### CaptionBar

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

```
val CaptionBar: WindowInsetsRulers
```

Rulers used for caption bar insets.

See [WindowInsetsCompat.Type.captionBar](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#captionBar())

### DisplayCutout

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

```
val DisplayCutout: WindowInsetsRulers
```

Rulers used for display cutout insets.

This is the safe insets that avoid all display cutouts. To get the bounds of the display cutouts themselves, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#(androidx.compose.ui.layout.Placeable.PlacementScope).getDisplayCutoutBounds()`.

See [WindowInsetsCompat.Type.displayCutout](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#displayCutout())

### Ime

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

```
val Ime: WindowInsetsRulers
```

Rulers used for IME insets.

See [WindowInsetsCompat.Type.ime](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#ime())

### MandatorySystemGestures

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

```
val MandatorySystemGestures: WindowInsetsRulers
```

Rulers used for mandatory system gestures insets.

See [WindowInsetsCompat.Type.mandatorySystemGestures](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#mandatorySystemGestures())

### NavigationBars

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

```
val NavigationBars: WindowInsetsRulers
```

Rulers used for navigation bars insets.

See [WindowInsetsCompat.Type.navigationBars](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#navigationBars())

### SafeContent

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

```
val SafeContent: WindowInsetsRulers
```

Rulers used for insets that are safe for any content. This includes `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SafeGestures()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SafeDrawing()`.

### SafeDrawing

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

```
val SafeDrawing: WindowInsetsRulers
```

Rulers used for insets including system bars, IME, and the display cutout.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SystemBars()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#DisplayCutout()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#Ime()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#TappableElement()` |   |

### SafeGestures

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

```
val SafeGestures: WindowInsetsRulers
```

Rulers used for insets that include places where gestures could conflict. This includes `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#MandatorySystemGestures()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#SystemGestures()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#TappableElement()`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#Waterfall()`.

### StatusBars

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

```
val StatusBars: WindowInsetsRulers
```

Rulers used for status bars insets.

See [WindowInsetsCompat.Type.statusBars](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#statusBars())

### SystemBars

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

```
val SystemBars: WindowInsetsRulers
```

Rulers used for system bars insets, including `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#StatusBars()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#NavigationBars()`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#CaptionBar()`.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.WindowInsetsRulers
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.Constraints

Layout(
    modifier = Modifier.fillMaxSize(),
    content = {
        Box(Modifier.background(Color.Blue)) // top area (e.g. status bar)
        Box(Modifier.background(Color.Yellow)) // bottom area (e.g. navigation bar)
        Box(Modifier.background(Color.White)) // content between top and bottom
    },
    measurePolicy = { measurables, constraints ->
        if (constraints.hasBoundedWidth && constraints.hasBoundedHeight) {
            val width = constraints.maxWidth
            val height = constraints.maxHeight
            layout(width, height) {
                val top =
                    maxOf(0, WindowInsetsRulers.SystemBars.current.top.current(0f).roundToInt())
                val topArea = measurables[0].measure(Constraints.fixed(width, top))
                topArea.place(0, 0)

                val bottom =
                    minOf(
                        height,
                        WindowInsetsRulers.SystemBars.current.bottom.current(0f).roundToInt(),
                    )
                val bottomArea =
                    measurables[1].measure(Constraints.fixed(width, height - bottom))
                bottomArea.place(0, bottom)

                val contentArea = measurables[2].measure(Constraints.fixed(width, bottom - top))
                contentArea.place(0, top)
            }
        } else {
            // It should only get here if inside scrollable content or trying to align
            // to an alignment line. Only place the content.
            val placeable = measurables[2].measure(constraints) // content
            layout(placeable.width, placeable.height) { placeable.place(0, 0) }
        }
    },
)
```

See [WindowInsetsCompat.Type.systemBars](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#systemBars())

### SystemGestures

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

```
val SystemGestures: WindowInsetsRulers
```

Rulers used for system gestures insets.

See [WindowInsetsCompat.Type.systemGestures](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#systemGestures())

### TappableElement

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

```
val TappableElement: WindowInsetsRulers
```

Rulers used for tappable elements insets.

See [WindowInsetsCompat.Type.tappableElement](https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type#tappableElement())

### Waterfall

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

```
val Waterfall: WindowInsetsRulers
```

Rulers used for waterfall insets.

See [DisplayCutoutCompat.getWaterfallInsets](https://developer.android.com/reference/androidx/core/view/DisplayCutoutCompat#getWaterfallInsets())

## Public functions

### getAnimation

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

```
fun getAnimation(scope: Placeable.PlacementScope): WindowInsetsAnimation
```

Additional properties related to animating this `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers`.

## Public properties

### current

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

```
val current: RectRulers
```

The current values for the window insets RectRulers. Values for some insets may not be provided on platforms that don't support specific Window Insets types. These also may not be provided if no `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` encroach on the content.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.WindowInsetsRulers
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.Constraints

Layout(
    modifier = Modifier.fillMaxSize(),
    content = {
        Box(Modifier.background(Color.Blue)) // top area (e.g. status bar)
        Box(Modifier.background(Color.Yellow)) // bottom area (e.g. navigation bar)
        Box(Modifier.background(Color.White)) // content between top and bottom
    },
    measurePolicy = { measurables, constraints ->
        if (constraints.hasBoundedWidth && constraints.hasBoundedHeight) {
            val width = constraints.maxWidth
            val height = constraints.maxHeight
            layout(width, height) {
                val top =
                    maxOf(0, WindowInsetsRulers.SystemBars.current.top.current(0f).roundToInt())
                val topArea = measurables[0].measure(Constraints.fixed(width, top))
                topArea.place(0, 0)

                val bottom =
                    minOf(
                        height,
                        WindowInsetsRulers.SystemBars.current.bottom.current(0f).roundToInt(),
                    )
                val bottomArea =
                    measurables[1].measure(Constraints.fixed(width, height - bottom))
                bottomArea.place(0, bottom)

                val contentArea = measurables[2].measure(Constraints.fixed(width, bottom - top))
                contentArea.place(0, top)
            }
        } else {
            // It should only get here if inside scrollable content or trying to align
            // to an alignment line. Only place the content.
            val placeable = measurables[2].measure(constraints) // content
            layout(placeable.width, placeable.height) { placeable.place(0, 0) }
        }
    },
)
```

### maximum

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

```
val maximum: RectRulers
```

The values for the insets when the insets are fully visible. The value does not change when the insets are hidden. Values for some insets may not be provided on some platforms. For example, values are never provided for `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#Ime()` on Android. These may not be provided if no `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers` encroach on the content.

When no animations are active, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` will have the same value if `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsAnimation#isVisible()` is `true`. If `false`, then `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()` will not be changed, while `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()` will have values the same as the Window borders. For example, when a status bar is visible, its height may be intrude 100 pixels into the Window and `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()`'s `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RectRulers#top()` will be at 100 pixels for `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#StatusBars()`. When the status bar is invisible, `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#maximum()` will have the same `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RectRulers#top()` value at 100 pixels, while `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/WindowInsetsRulers#current()`'s `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RectRulers#top()` will be at 0 pixels.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.WindowInsetsRulers
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.Constraints

// When the status bar is visible, don't show the content that would be in the status area.
// When the status bar is hidden, show content that would be in the status area.
Layout(
    modifier = Modifier.fillMaxSize(),
    content = {
        Box(Modifier.background(Color.Blue)) // status bar area content
        Box(Modifier.background(Color.Yellow)) // normal content
    },
    measurePolicy = { measurables, constraints ->
        val width = constraints.maxWidth
        val height = constraints.maxHeight
        layout(width, height) {
            val top = WindowInsetsRulers.StatusBars.maximum.top.current(0f).roundToInt()
            val statusBarAnimationProperties = WindowInsetsRulers.StatusBars.getAnimation(this)
            if (!statusBarAnimationProperties.isVisible) {
                // Only place the status bar content when the status bar isn't visible. We don't
                // want it cluttering the status bar area when the status bar is shown.
                measurables[0].measure(Constraints.fixed(width, top)).place(0, 0)
            }
            // Place the normal content below where the status bar would be.
            measurables[1].measure(Constraints.fixed(width, height - top)).place(0, top)
        }
    },
)
```