Android 12 Developer Preview is here! Try it out, and give us your feedback!

WindowMetrics

public final class WindowMetrics
extends Object

java.lang.Object
   ↳ androidx.window.WindowMetrics


Metrics about a Window, consisting of its bounds.

This is usually obtained from WindowManager.getCurrentWindowMetrics() or WindowManager.getMaximumWindowMetrics().

Summary

Public constructors

WindowMetrics(Rect bounds)

Constructs a new WindowMetrics instance.

Public methods

boolean equals(Object o)
Rect getBounds()

Returns a new Rect describing the bounds of the area the window occupies.

int hashCode()

Inherited methods

Public constructors

WindowMetrics

public WindowMetrics (Rect bounds)

Constructs a new WindowMetrics instance.

Parameters
bounds Rect: rect describing the bounds of the window, see getBounds().

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getBounds

public Rect getBounds ()

Returns a new Rect describing the bounds of the area the window occupies.

Note that the size of the reported bounds can have different size than Display.getSize(Point). This method reports the window size including all system decorations, while Display.getSize(Point) reports the area excluding navigation bars and display cutout areas.

Returns
Rect window bounds in pixels.

hashCode

public int hashCode ()

Returns
int