The Android Developer Challenge is back! Submit your idea before December 2.

WindowInsetsCompat

open class WindowInsetsCompat
kotlin.Any
   ↳ androidx.core.view.WindowInsetsCompat

Describes a set of insets for window content.

WindowInsetsCompats 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 WindowInsetsCompat instance with the adjusted properties.

Summary

Public constructors

Constructs a new WindowInsetsCompat, copying all values from a source WindowInsetsCompat.

Public methods

open WindowInsetsCompat!

Returns a copy of this WindowInsets with the cutout fully consumed.

open WindowInsetsCompat!

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

open WindowInsetsCompat!

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

open Boolean
equals(other: Any?)

open DisplayCutoutCompat?

Returns the display cutout if there is one.

open Insets

Returns the mandatory system gesture insets.

open Int

Returns the bottom stable inset in pixels.

open Int

Returns the left stable inset in pixels.

open Int

Returns the right stable inset in pixels.

open Int

Returns the top stable inset in pixels.

open Insets

Returns the stable insets in pixels.

open Insets

Returns the system gesture insets.

open Int

Returns the bottom system window inset in pixels.

open Int

Returns the left system window inset in pixels.

open Int

Returns the right system window inset in pixels.

open Int

Returns the top system window inset in pixels.

open Insets

Returns the system window insets in pixels.

open Insets

Returns the tappable element insets.

open Boolean

Returns true if this WindowInsets has any nonzero insets.

open Boolean

Returns true if this WindowInsets has nonzero stable insets.

open Boolean

Returns true if this WindowInsets has nonzero system window insets.

open Int

open Boolean

Check if these insets have been fully consumed.

open Boolean

Returns true if the associated window has a round shape.

open WindowInsetsCompat!
replaceSystemWindowInsets(left: Int, top: Int, right: Int, bottom: Int)

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

open WindowInsetsCompat!
replaceSystemWindowInsets(systemWindowInsets: Rect!)

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

open WindowInsets?

Return the source WindowInsets instance used in this WindowInsetsCompat.

open static WindowInsetsCompat

Wrap an instance of WindowInsets into a WindowInsetsCompat.

Public constructors

<init>

WindowInsetsCompat(src: WindowInsetsCompat!)

Constructs a new WindowInsetsCompat, copying all values from a source WindowInsetsCompat.

Parameters
src WindowInsetsCompat!: source from which values are copied

Public methods

consumeDisplayCutout

open fun consumeDisplayCutout(): WindowInsetsCompat!

Returns a copy of this WindowInsets with the cutout fully consumed.

Return
WindowInsetsCompat!: A modified copy of this WindowInsets

consumeStableInsets

open fun consumeStableInsets(): WindowInsetsCompat!

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

Return
WindowInsetsCompat!: A modified copy of this WindowInsetsCompat

consumeSystemWindowInsets

open fun consumeSystemWindowInsets(): WindowInsetsCompat!

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

Return
WindowInsetsCompat!: A modified copy of this WindowInsets

equals

open fun equals(other: Any?): Boolean

getDisplayCutout

@Nullable open fun getDisplayCutout(): DisplayCutoutCompat?

Returns the display cutout if there is one.

Return
DisplayCutoutCompat?: the display cutout or null if there is none

getMandatorySystemGestureInsets

@NonNull open fun getMandatorySystemGestureInsets(): Insets

Returns the mandatory system gesture insets.

The mandatory system gesture insets represent the area of a window where mandatory system gestures have priority and may consume some or all touch input, e.g. due to the a system bar occupying it, or it being reserved for touch-only gestures.

getStableInsetBottom

open fun getStableInsetBottom(): Int

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.

Return
Int: The bottom stable inset

getStableInsetLeft

open fun getStableInsetLeft(): Int

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.

Return
Int: The left stable inset

getStableInsetRight

open fun getStableInsetRight(): Int

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.

Return
Int: The right stable inset

getStableInsetTop

open fun getStableInsetTop(): Int

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.

Return
Int: The top stable inset

getStableInsets

@NonNull open fun getStableInsets(): Insets

Returns the stable insets 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.

Return
Insets: The stable insets

getSystemGestureInsets

@NonNull open fun getSystemGestureInsets(): Insets

Returns the system gesture insets.

The system gesture insets represent the area of a window where system gestures have priority and may consume some or all touch input, e.g. due to the a system bar occupying it, or it being reserved for touch-only gestures.

An app can declare priority over system gestures with android.view.View#setSystemGestureExclusionRects outside of the mandatory system gesture insets.

getSystemWindowInsetBottom

open fun getSystemWindowInsetBottom(): Int

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.

Return
Int: The bottom system window inset

getSystemWindowInsetLeft

open fun getSystemWindowInsetLeft(): Int

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.

Return
Int: The left system window inset

getSystemWindowInsetRight

open fun getSystemWindowInsetRight(): Int

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.

Return
Int: The right system window inset

getSystemWindowInsetTop

open fun getSystemWindowInsetTop(): Int

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.

Return
Int: The top system window inset

getSystemWindowInsets

@NonNull open fun getSystemWindowInsets(): Insets

Returns the system window insets 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.

Return
Insets: The system window insets

getTappableElementInsets

@NonNull open fun getTappableElementInsets(): Insets

Returns the tappable element insets.

The tappable element insets represent how much tappable elements must at least be inset to remain both tappable and visually unobstructed by persistent system windows.

This may be smaller than getSystemWindowInsets() if the system window is largely transparent and lets through simple taps (but not necessarily more complex gestures).

hasInsets

open fun hasInsets(): Boolean

Returns true if this WindowInsets has any nonzero insets.

Return
Boolean: true if any inset values are nonzero

hasStableInsets

open fun hasStableInsets(): Boolean

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.

Return
Boolean: true if any of the stable inset values are nonzero

hasSystemWindowInsets

open fun hasSystemWindowInsets(): Boolean

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.

Return
Boolean: true if any of the system window inset values are nonzero

hashCode

open fun hashCode(): Int

isConsumed

open fun isConsumed(): Boolean

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 android.view.View#fitSystemWindows(android.graphics.Rect).

Return
Boolean: true if the insets have been fully consumed.

isRound

open fun isRound(): Boolean

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.

Return
Boolean: True if the window is round

replaceSystemWindowInsets

open fun replaceSystemWindowInsets(left: Int, top: Int, right: Int, bottom: Int): WindowInsetsCompat!

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
Return
WindowInsetsCompat!: A modified copy of this WindowInsets

replaceSystemWindowInsets

open fun replaceSystemWindowInsets(systemWindowInsets: Rect!): WindowInsetsCompat!

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
Return
WindowInsetsCompat!: A modified copy of this WindowInsets

toWindowInsets

@Nullable open fun toWindowInsets(): WindowInsets?

Return the source WindowInsets instance used in this WindowInsetsCompat.

Return
WindowInsets?: the wrapped WindowInsets instance

toWindowInsetsCompat

@NonNull open static fun toWindowInsetsCompat(@NonNull insets: WindowInsets): WindowInsetsCompat

Wrap an instance of WindowInsets into a WindowInsetsCompat.

Parameters
insets WindowInsets: source insets to wrap
Return
WindowInsetsCompat: the wrapped instance