# androidx.window.core.layout

*** ** * ** ***

Common/All

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowHeightSizeClass` | **This class is deprecated.** WindowHeightSizeClass will not be developed further, use WindowSizeClass instead. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` represents breakpoints for a viewport. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowWidthSizeClass` | **This class is deprecated.** WindowWidthSizeClass will not be developed further, use WindowSizeClass instead. | Cmn |

## Top-level functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#createGridWindowSizeClassSet(kotlin.collections.Set,kotlin.collections.Set)( minWidthDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, minHeightDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html> )` Creates a new set of breakpoints by taking the cross product of `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#createGridWindowSizeClassSet(kotlin.collections.Set,kotlin.collections.Set)` and `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#createGridWindowSizeClassSet(kotlin.collections.Set,kotlin.collections.Set)`. | Cmn |

## Extension functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>.https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).addHeightDpBreakpoints(kotlin.collections.Set)( minHeightDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html> )` Creates a new `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` that contains the original `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` values in addition to new elements where the width is from the original set and the height is from `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).addHeightDpBreakpoints(kotlin.collections.Set)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>.https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)( widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`). | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>.https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)(widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`). | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>.https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)( widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`). | Cmn |

## Top-level functions

### createGridWindowSizeClassSet

Cmn Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClassGridCreator.kt+function:createGridWindowSizeClassSet) Added in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
fun createGridWindowSizeClassSet(
    minWidthDpBreakPoints: Set<Int>,
    minHeightDpBreakPoints: Set<Int>
): Set<WindowSizeClass>
```

Creates a new set of breakpoints by taking the cross product of `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#createGridWindowSizeClassSet(kotlin.collections.Set,kotlin.collections.Set)` and `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#createGridWindowSizeClassSet(kotlin.collections.Set,kotlin.collections.Set)`. For example, if the width set is {10, 20} and the height set is { 100, 200 } then the resulting set will be { (10, 100), (10, 200), (20, 100), (20, 200) }.

| Parameters |
|---|---|
| `minWidthDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | the width breakpoints in DP to construct the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` |
| `minHeightDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | the height breakpoints in DP to construct the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` containing the breakpoints using a grid style |

## Extension functions

### Set.addHeightDpBreakpoints

Cmn Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClassGridCreator.kt+function:addHeightDpBreakpoints) Added in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
fun Set<WindowSizeClass>.addHeightDpBreakpoints(
    minHeightDpBreakPoints: Set<Int>
): Set<WindowSizeClass>
```

Creates a new `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` that contains the original `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` values in addition to new elements where the width is from the original set and the height is from `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).addHeightDpBreakpoints(kotlin.collections.Set)`. Note this method does not fill in any gaps in the original set. For example if the original set was { (10, 10), (20, 20) } and the height set is { 30 } the new set will be { (10, 10), (20, 20), (10, 30), (20, 30) }. To maintain a grid set the source set must also be a grid set.

| Parameters |
|---|---|
| `minHeightDpBreakPoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | the height breakpoints in DP to construct the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass>` | a new `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` that contains (minWidthDp, minHeightDp) for each pair possible taking the \* height breakpoint from `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).addHeightDpBreakpoints(kotlin.collections.Set)` and the width breakpoint from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html`. |

### Set.computeWindowSizeClass

Cmn Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClassSelectors.kt+function:computeWindowSizeClass) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun Set<WindowSizeClass>.computeWindowSizeClass(
    widthDp: Float,
    heightDp: Float
): WindowSizeClass
```

Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`). This method prefers width and uses max height to break ties. If there is no match a default of `WindowSizeClass(0,0)` is returned. Examples: Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600)` widthDp: `300.5f` heightDp: `800.5f` Output: `WindowSizeClass(300, 600)` Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600)` widthDp: `300` heightDp: `400` Output: `WindowSizeClass(300, 300)`. This is an overload that truncates the floats to integers.

| Parameters |
|---|---|
| `widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the width of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |
| `heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the height of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)` |   |

### Set.computeWindowSizeClass

Cmn Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClassSelectors.kt+function:computeWindowSizeClass) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun Set<WindowSizeClass>.computeWindowSizeClass(widthDp: Int, heightDp: Int): WindowSizeClass
```

Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`). This method prefers width and uses max height to break ties. If there is no match a default of `WindowSizeClass(0,0)` is returned. Examples: Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600)` widthDp: `300` heightDp: `800` Output: `WindowSizeClass(300, 600)` Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(300, 600)` widthDp: `300` heightDp: `400` Output: `WindowSizeClass(300, 300)`

| Parameters |
|---|---|
| `widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the width of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |
| `heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the height of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |

### Set.computeWindowSizeClassPreferHeight

Cmn Artifact: [androidx.window:window-core](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/core/layout/WindowSizeClassSelectors.kt+function:computeWindowSizeClassPreferHeight) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
fun Set<WindowSizeClass>.computeWindowSizeClassPreferHeight(
    widthDp: Int,
    heightDp: Int
): WindowSizeClass
```

Returns the largest `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`). This method prefers height and uses max width to break ties. If there is no match a default of `WindowSizeClass(0,0)` is returned. Examples: Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300)` widthDp: `800` heightDp: `300` Output: `WindowSizeClass(600, 300)` Input: Set: `setOf(WindowSizeClass(300, 300), WindowSizeClass(600, 300)` widthDp: `400` heightDp: `300` Output: `WindowSizeClass(300, 300)`

| Parameters |
|---|---|
| `widthDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the width of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |
| `heightDp: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the height of the window to match a `https://developer.android.com/reference/kotlin/androidx/window/core/layout/WindowSizeClass` to. |