# WindowMetrics

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/window/layout/WindowMetrics "View this page in Java")

<br />

```
class WindowMetrics
```

<br />

*** ** * ** ***

Metrics about a[android.view.Window](https://developer.android.com/reference/android/view/Window.html), consisting of its bounds.

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

|                                                         See also                                                         |
|--------------------------------------------------------------------------------------------------------------------------|---|
| [WindowMetricsCalculator](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetricsCalculator) |   |

## Summary

|                                        ### Public functions                                         |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `open operator `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [equals](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#equals(kotlin.Any))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)` |
| `open `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                  | [hashCode](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#hashCode())`()`                                                                                            |
| `open `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)            | [toString](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#toString())`()`                                                                                            |

|                              ### Public properties                              |
|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Rect](https://developer.android.com/reference/android/graphics/Rect.html)      | [bounds](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#bounds()) Returns a new[Rect](https://developer.android.com/reference/android/graphics/Rect.html)describing the bounds of the area the window occupies.                    |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [density](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#density()) Returns the logical density of the display this window is in.                                                                                                  |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [heightDp](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#heightDp()) Returns the height of the[Rect](https://developer.android.com/reference/android/graphics/Rect.html)in DP units including insets from all system decorations. |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [widthDp](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowMetrics#widthDp()) Returns the width of the[Rect](https://developer.android.com/reference/android/graphics/Rect.html)in DP units including insets from all system decorations.    |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```  

### hashCode

```
open fun hashCode(): Int
```  

### toString

```
open fun toString(): String
```  

## Public properties

### bounds

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

```
val bounds: Rect
```

Returns a new[Rect](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[android.view.Display.getSize](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[android.view.Display.getSize](https://developer.android.com/reference/android/view/Display.html#getSize(android.graphics.Point))reports the area excluding navigation bars and display cutout areas.  

|                                  Returns                                   |
|----------------------------------------------------------------------------|--------------------------|
| [Rect](https://developer.android.com/reference/android/graphics/Rect.html) | window bounds in pixels. |

### density

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

```
val density: Float
```

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

|                                           See also                                            |
|-----------------------------------------------------------------------------------------------|---|
| [density](https://developer.android.com/reference/android/util/DisplayMetrics.html#density()) |   |

### heightDp

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

```
val heightDp: Float
```

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

### widthDp

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

```
val widthDp: Float
```

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