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 consumeStableInsets()
Returns a copy of this WindowInsets with the stable insets fully consumed.
WindowInsets consumeSystemWindowInsets()
Returns a copy of this WindowInsets with the system window insets fully consumed.
int getStableInsetBottom()
Returns the bottom stable inset in pixels.
int getStableInsetLeft()
Returns the left stable inset in pixels.
int getStableInsetRight()
Returns the right stable inset in pixels.
int getStableInsetTop()
Returns the top stable inset in pixels.
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 hasStableInsets()
Returns true if this WindowInsets has nonzero stable insets.
boolean hasSystemWindowInsets()
Returns true if this WindowInsets has nonzero system window insets.
boolean isConsumed()
Check if these insets have been fully consumed.
boolean isRound()
Returns true if the associated window has a round shape.
WindowInsets replaceSystemWindowInsets(Rect systemWindowInsets)
Returns a copy of this WindowInsets with selected system window insets replaced with new values.
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 consumeStableInsets ()

Added in API level 21

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

Returns
  • A modified copy of this WindowInsets

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 getStableInsetBottom ()

Added in API level 21

Returns the bottom stable inset in pixels.

The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.

Returns
  • The bottom stable inset

public int getStableInsetLeft ()

Added in API level 21

Returns the left stable inset in pixels.

The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.

Returns
  • The left stable inset

public int getStableInsetRight ()

Added in API level 21

Returns the right stable inset in pixels.

The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.

Returns
  • The right stable inset

public int getStableInsetTop ()

Added in API level 21

Returns the top stable inset in pixels.

The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.

Returns
  • The top stable inset

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 hasStableInsets ()

Added in API level 21

Returns true if this WindowInsets has nonzero stable insets.

The stable inset represents the area of a full-screen window that may be partially or fully obscured by the system UI elements. This value does not change based on the visibility state of those elements; for example, if the status bar is normally shown, but temporarily hidden, the stable inset will still provide the inset associated with the status bar being shown.

Returns
  • true if any of the stable 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 isConsumed ()

Added in API level 21

Check if these insets have been fully consumed.

Insets are considered "consumed" if the applicable consume* methods have been called such that all insets have been set to zero. This affects propagation of insets through the view hierarchy; insets that have not been fully consumed will continue to propagate down to child views.

The result of this method is equivalent to the return value of fitSystemWindows(android.graphics.Rect).

Returns
  • true if the insets have been fully consumed.

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 (Rect systemWindowInsets)

Added in API level 21

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

Parameters
systemWindowInsets New system window insets. Each field is the inset in pixels for that edge
Returns
  • A modified copy of this WindowInsets

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.