# WindowMetrics

Artifact: [androidx.window:window](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/layout/WindowMetrics.kt+class:androidx.window.layout.WindowMetrics) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0)

*** ** * ** ***


```
public final class WindowMetrics
```

<br />

*** ** * ** ***

Metrics about a `https://developer.android.com/reference/android/view/Window.html`, consisting of its bounds.

This is obtained from `https://developer.android.com/reference/androidx/window/layout/WindowMetricsCalculator#computeCurrentWindowMetrics(android.app.Activity)` or `https://developer.android.com/reference/androidx/window/layout/WindowMetricsCalculator#computeMaximumWindowMetrics(android.app.Activity)`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowMetricsCalculator` |   |

## Summary

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#getBounds()()` Returns a new `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the area the window occupies. |
| `final float` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#getDensity()()` Returns the logical density of the display this window is in. |
| `final float` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#getHeightDp()()` Returns the height of the `https://developer.android.com/reference/android/graphics/Rect.html` in DP units including insets from all system decorations. |
| `final float` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#getWidthDp()()` Returns the width of the `https://developer.android.com/reference/android/graphics/Rect.html` in DP units including insets from all system decorations. |
| `int` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/window/layout/WindowMetrics#toString()()` |

## Public methods

### equals

```
public boolean equals(Object other)
```

### getBounds

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0)

```
public final @NonNull Rect getBounds()
```

Returns a new `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the area the window occupies.

**Note that the size of the reported bounds can have different size than `https://developer.android.com/reference/android/view/Display.html#getSize(android.graphics.Point)`.** This method reports the window size including insets from all system decorations, while `https://developer.android.com/reference/android/view/Display.html#getSize(android.graphics.Point)` reports the area excluding navigation bars and display cutout areas.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | window bounds in pixels. |

### getDensity

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
public final float getDensity()
```

Returns the logical density of the display this window is in.

| See also |
|---|---|
| `https://developer.android.com/reference/android/util/DisplayMetrics.html#density` |   |

### getHeightDp

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
public final float getHeightDp()
```

Returns the height of the `https://developer.android.com/reference/android/graphics/Rect.html` in DP units including insets from all system decorations.

### getWidthDp

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
public final float getWidthDp()
```

Returns the width of the `https://developer.android.com/reference/android/graphics/Rect.html` in DP units including insets from all system decorations.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```