Android APIs
public final class

WindowInsets

extends Object
java.lang.Object
   ↳ android.view.WindowInsets

Class Overview

Describes a set of insets for window content.

WindowInsets are immutable and may be expanded to include more inset types in the future. To adjust insets, use one of the supplied clone methods to obtain a new WindowInsets instance with the adjusted properties.

Summary

Public Constructors
WindowInsets(WindowInsets src)
Construct a new WindowInsets, copying all values from a source WindowInsets.
Public Methods
WindowInsets consumeSystemWindowInsets()
Returns a copy of this WindowInsets with the system window insets fully consumed.
int getSystemWindowInsetBottom()
Returns the bottom system window inset in pixels.
int getSystemWindowInsetLeft()
Returns the left system window inset in pixels.
int getSystemWindowInsetRight()
Returns the right system window inset in pixels.
int getSystemWindowInsetTop()
Returns the top system window inset in pixels.
boolean hasInsets()
Returns true if this WindowInsets has any nonzero insets.
boolean hasSystemWindowInsets()
Returns true if this WindowInsets has nonzero system window insets.
boolean isRound()
Returns true if the associated window has a round shape.
WindowInsets replaceSystemWindowInsets(int left, int top, int right, int bottom)
Returns a copy of this WindowInsets with selected system window insets replaced with new values.
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public WindowInsets (WindowInsets src)

Added in API level 20

Construct a new WindowInsets, copying all values from a source WindowInsets.

Parameters
src Source to copy insets from

Public Methods

public WindowInsets consumeSystemWindowInsets ()

Added in API level 20

Returns a copy of this WindowInsets with the system window insets fully consumed.

Returns
  • A modified copy of this WindowInsets

public int getSystemWindowInsetBottom ()

Added in API level 20

Returns the bottom system window inset in pixels.

The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.

Returns
  • The bottom system window inset

public int getSystemWindowInsetLeft ()

Added in API level 20

Returns the left system window inset in pixels.

The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.

Returns
  • The left system window inset

public int getSystemWindowInsetRight ()

Added in API level 20

Returns the right system window inset in pixels.

The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.

Returns
  • The right system window inset

public int getSystemWindowInsetTop ()

Added in API level 20

Returns the top system window inset in pixels.

The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.

Returns
  • The top system window inset

public boolean hasInsets ()

Added in API level 20

Returns true if this WindowInsets has any nonzero insets.

Returns
  • true if any inset values are nonzero

public boolean hasSystemWindowInsets ()

Added in API level 20

Returns true if this WindowInsets has nonzero system window insets.

The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows.

Returns
  • true if any of the system window inset values are nonzero

public boolean isRound ()

Added in API level 20

Returns true if the associated window has a round shape.

A round window's left, top, right and bottom edges reach all the way to the associated edges of the window but the corners may not be visible. Views responding to round insets should take care to not lay out critical elements within the corners where they may not be accessible.

Returns
  • True if the window is round

public WindowInsets replaceSystemWindowInsets (int left, int top, int right, int bottom)

Added in API level 20

Returns a copy of this WindowInsets with selected system window insets replaced with new values.

Parameters
left New left inset in pixels
top New top inset in pixels
right New right inset in pixels
bottom New bottom inset in pixels
Returns
  • A modified copy of this WindowInsets

public String toString ()

Added in API level 20

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.