# WindowSizeClassSelectors

Added in 1.4.0

*** ** * ** ***


```
public final class WindowSizeClassSelectors
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` | `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClassSelectors#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass> receiver, float widthDp, float heightDp )` Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`). |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` | `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClassSelectors#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass> receiver, int widthDp, int heightDp )` Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`). |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` | `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClassSelectors#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass> receiver, int widthDp, int heightDp )` Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`). |

## Public methods

### computeWindowSizeClass

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)

```
public static final @NonNull WindowSizeClass computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    float widthDp,
    float heightDp
)
```

Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/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 |
|---|---|
| `float widthDp` | the width of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |
| `float heightDp` | the height of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |

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

### computeWindowSizeClass

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)

```
public static final @NonNull WindowSizeClass computeWindowSizeClass(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)
```

Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClass(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/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 |
|---|---|
| `int widthDp` | the width of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |
| `int heightDp` | the height of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |

### computeWindowSizeClassPreferHeight

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)

```
public static final @NonNull WindowSizeClass computeWindowSizeClassPreferHeight(
    @NonNull Set<@NonNull WindowSizeClass> receiver,
    int widthDp,
    int heightDp
)
```

Returns the largest `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` that is within the bounds of (`https://developer.android.com/reference/androidx/window/core/layout/package-summary#(kotlin.collections.Set).computeWindowSizeClassPreferHeight(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/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 |
|---|---|
| `int widthDp` | the width of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |
| `int heightDp` | the height of the window to match a `https://developer.android.com/reference/androidx/window/core/layout/WindowSizeClass` to. |