WindowMetrics


public final class WindowMetrics


Metrics about a android.view.Window, consisting of its bounds.

This is obtained from WindowMetricsCalculator.computeCurrentWindowMetrics or WindowMetricsCalculator.computeMaximumWindowMetrics.

Summary

Public methods

boolean
equals(Object other)
final @NonNull Rect

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

final float

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

final float

Returns the height of the Rect in DP units including insets from all system decorations.

final float

Returns the width of the Rect in DP units including insets from all system decorations.

int
@NonNull String

Public methods

equals

public boolean equals(Object other)

getBounds

Added in 1.0.0
public final @NonNull 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 android.view.Display.getSize. This method reports the window size including insets from all system decorations, while android.view.Display.getSize reports the area excluding navigation bars and display cutout areas.

Returns
@NonNull Rect

window bounds in pixels.

getDensity

Added in 1.4.0-alpha05
public final float getDensity()

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

See also
density

getHeightDp

Added in 1.4.0-alpha05
public final float getHeightDp()

Returns the height of the Rect in DP units including insets from all system decorations.

getWidthDp

Added in 1.4.0-alpha05
public final float getWidthDp()

Returns the width of the Rect in DP units including insets from all system decorations.

hashCode

public int hashCode()

toString

public @NonNull String toString()