Skip to content

Most visited

Recently visited

navigation
Added in API level 20

WindowInsets

public final class WindowInsets
extends Object

java.lang.Object
   ↳ android.view.WindowInsets


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.

See also:

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.

Inherited methods

From class java.lang.Object

Public constructors

WindowInsets

Added in API level 20
WindowInsets (WindowInsets src)

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

Parameters
src WindowInsets: Source to copy insets from

Public methods

consumeStableInsets

Added in API level 21
WindowInsets consumeStableInsets ()

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

Returns
WindowInsets A modified copy of this WindowInsets

consumeSystemWindowInsets

Added in API level 20
WindowInsets consumeSystemWindowInsets ()

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

Returns
WindowInsets A modified copy of this WindowInsets

getStableInsetBottom

Added in API level 21
int getStableInsetBottom ()

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
int The bottom stable inset

getStableInsetLeft

Added in API level 21
int getStableInsetLeft ()

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
int The left stable inset

getStableInsetRight

Added in API level 21
int getStableInsetRight ()

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
int The right stable inset

getStableInsetTop

Added in API level 21
int getStableInsetTop ()

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
int The top stable inset

getSystemWindowInsetBottom

Added in API level 20
int getSystemWindowInsetBottom ()

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
int The bottom system window inset

getSystemWindowInsetLeft

Added in API level 20
int getSystemWindowInsetLeft ()

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
int The left system window inset

getSystemWindowInsetRight

Added in API level 20
int getSystemWindowInsetRight ()

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
int The right system window inset

getSystemWindowInsetTop

Added in API level 20
int getSystemWindowInsetTop ()

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
int The top system window inset

hasInsets

Added in API level 20
boolean hasInsets ()

Returns true if this WindowInsets has any nonzero insets.

Returns
boolean true if any inset values are nonzero

hasStableInsets

Added in API level 21
boolean hasStableInsets ()

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
boolean true if any of the stable inset values are nonzero

hasSystemWindowInsets

Added in API level 20
boolean hasSystemWindowInsets ()

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
boolean true if any of the system window inset values are nonzero

isConsumed

Added in API level 21
boolean isConsumed ()

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
boolean true if the insets have been fully consumed.

isRound

Added in API level 20
boolean isRound ()

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
boolean True if the window is round

replaceSystemWindowInsets

Added in API level 21
WindowInsets replaceSystemWindowInsets (Rect systemWindowInsets)

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

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

replaceSystemWindowInsets

Added in API level 20
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.

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

toString

Added in API level 20
String toString ()

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
String a printable representation of this object.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.