WindowInsets.Builder

public static final class WindowInsets.Builder
extends Object

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


Builder for WindowInsets.

Summary

Public constructors

WindowInsets.Builder()

Creates a builder where all insets are initially consumed.

WindowInsets.Builder(WindowInsets insets)

Creates a builder where all insets are initialized from WindowInsets.

Public methods

WindowInsets build()

Builds a WindowInsets instance.

WindowInsets.Builder setDisplayCutout(DisplayCutout displayCutout)

Sets the display cutout.

WindowInsets.Builder setMandatorySystemGestureInsets(Insets insets)

Sets mandatory system gesture insets in pixels.

WindowInsets.Builder setStableInsets(Insets stableInsets)

Sets the stable insets in pixels.

WindowInsets.Builder setSystemGestureInsets(Insets insets)

Sets system gesture insets in pixels.

WindowInsets.Builder setSystemWindowInsets(Insets systemWindowInsets)

Sets system window insets in pixels.

WindowInsets.Builder setTappableElementInsets(Insets insets)

Sets tappable element insets in pixels.

Inherited methods

Public constructors

WindowInsets.Builder

Added in API level 29
public WindowInsets.Builder ()

Creates a builder where all insets are initially consumed.

WindowInsets.Builder

Added in API level 29
public WindowInsets.Builder (WindowInsets insets)

Creates a builder where all insets are initialized from WindowInsets.

Parameters
insets WindowInsets: the instance to initialize from. This value must never be null.

Public methods

build

Added in API level 29
public WindowInsets build ()

Builds a WindowInsets instance.

Returns
WindowInsets the WindowInsets instance. This value will never be null.

setDisplayCutout

Added in API level 29
public WindowInsets.Builder setDisplayCutout (DisplayCutout displayCutout)

Sets the display cutout.

Parameters
displayCutout DisplayCutout: the display cutout or null if there is none This value may be null.

Returns
WindowInsets.Builder itself

setMandatorySystemGestureInsets

Added in API level 29
public WindowInsets.Builder setMandatorySystemGestureInsets (Insets insets)

Sets mandatory system gesture insets in pixels.

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.

In contrast to regular system gestures, mandatory system gestures cannot be overriden by View#setSystemGestureExclusionRects.

Parameters
insets Insets: This value must never be null.

Returns
WindowInsets.Builder itself This value will never be null.

setStableInsets

Added in API level 29
public WindowInsets.Builder setStableInsets (Insets stableInsets)

Sets 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.

Parameters
stableInsets Insets: This value must never be null.

Returns
WindowInsets.Builder itself This value will never be null.

setSystemGestureInsets

Added in API level 29
public WindowInsets.Builder setSystemGestureInsets (Insets insets)

Sets system gesture insets in pixels.

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.

Parameters
insets Insets: This value must never be null.

Returns
WindowInsets.Builder itself This value will never be null.

setSystemWindowInsets

Added in API level 29
public WindowInsets.Builder setSystemWindowInsets (Insets systemWindowInsets)

Sets 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.

Parameters
systemWindowInsets Insets: This value must never be null.

Returns
WindowInsets.Builder itself This value will never be null.

setTappableElementInsets

Added in API level 29
public WindowInsets.Builder setTappableElementInsets (Insets insets)

Sets tappable element insets in pixels.

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.

Parameters
insets Insets: This value must never be null.

Returns
WindowInsets.Builder itself This value will never be null.