# HeightSizeClass

Artifact: [androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/sizeclass/HeightSizeClass.kt+class:androidx.test.espresso.device.sizeclass.HeightSizeClass)

*** ** * ** ***


```
public final class HeightSizeClass
```

<br />

*** ** * ** ***

A class to create buckets for the height of a window.

For details on window size classes, see https://developer.android.com/guide/topics/large-screens/support-different-screen-sizes.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion` |
| `public enum https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum extends https://developer.android.com/reference/java/lang/Enum.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum>` |

| ### Public fields |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#COMPACT()` A bucket to represent a compact height. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#EXPANDED()` A bucket to represent an expanded height window. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#MEDIUM()` A bucket to represent a medium height. |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#compute(kotlin.Int)(int dpHeight)` Returns a recommended `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` for the height of a window given the height in DP. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#getEnum(androidx.test.espresso.device.sizeclass.HeightSizeClass)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass sizeClass)` Returns a `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum` given the `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass`. |
| `static final int` | `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass#getHeightDpInSizeClass(androidx.test.espresso.device.sizeclass.HeightSizeClass)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass sizeClass)` Returns a recommended height of a window in DP given the `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass`. |

## Public fields

### COMPACT

```
public static final @NonNull HeightSizeClass COMPACT
```

A bucket to represent a compact height. One use-case is a phone that is in landscape.

### EXPANDED

```
public static final @NonNull HeightSizeClass EXPANDED
```

A bucket to represent an expanded height window. One use-case is a tablet or a desktop app.

### MEDIUM

```
public static final @NonNull HeightSizeClass MEDIUM
```

A bucket to represent a medium height. One use-case is a phone in portrait or a tablet.

## Public methods

### compute

```
public static final @NonNull HeightSizeClass compute(int dpHeight)
```

Returns a recommended `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` for the height of a window given the height in DP.

| Parameters |
|---|---|
| `int dpHeight` | the height of the window in DP |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass` | A recommended size class for the height |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the height is negative |

### getEnum

```
public static final @NonNull HeightSizeClass.Companion.HeightSizeClassEnum getEnum(@NonNull HeightSizeClass sizeClass)
```

Returns a `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum` given the `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass sizeClass` | the size class |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass.Companion.HeightSizeClassEnum` | the relevant HeightSizeClassEnum |

### getHeightDpInSizeClass

```
public static final int getHeightDpInSizeClass(@NonNull HeightSizeClass sizeClass)
```

Returns a recommended height of a window in DP given the `https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/sizeclass/HeightSizeClass sizeClass` | the size class |

| Returns |
|---|---|
| `int` | A recommended height in DP in this size class |