WindowInsetsCompat.Builder

Added in 1.3.0

public final class WindowInsetsCompat.Builder


Builder for WindowInsetsCompat.

Summary

Public constructors

Creates a builder where all insets are initially consumed.

Creates a builder where all insets are initialized from WindowInsetsCompat.

Public methods

@NonNull WindowInsetsCompat

Builds a WindowInsetsCompat instance.

@NonNull WindowInsetsCompat.Builder

Sets the display cutout.

@NonNull WindowInsetsCompat.Builder
setInsets(int typeMask, @NonNull Insets insets)

Sets the insets of a specific window type in pixels.

@NonNull WindowInsetsCompat.Builder
setInsetsIgnoringVisibility(int typeMask, @NonNull Insets insets)

Sets the insets a specific window type in pixels, while ignoring its visibility state.

@NonNull WindowInsetsCompat.Builder

This method is deprecated.

Use setInsets with mandatorySystemGestures.

@NonNull WindowInsetsCompat.Builder

This method is deprecated.

Use setInsetsIgnoringVisibility with systemBars.

@NonNull WindowInsetsCompat.Builder

This method is deprecated.

Use setInsets with systemGestures.

@NonNull WindowInsetsCompat.Builder

This method is deprecated.

Use setInsets with systemBars.

@NonNull WindowInsetsCompat.Builder

This method is deprecated.

Use setInsets with tappableElement.

@NonNull WindowInsetsCompat.Builder
setVisible(int typeMask, boolean visible)

Sets whether windows that can cause insets are currently visible on screen.

Public constructors

Builder

Added in 1.3.0
public Builder()

Creates a builder where all insets are initially consumed.

Builder

Added in 1.3.0
public Builder(@NonNull WindowInsetsCompat insets)

Creates a builder where all insets are initialized from WindowInsetsCompat.

Parameters
@NonNull WindowInsetsCompat insets

the instance to initialize from.

Public methods

build

Added in 1.3.0
public @NonNull WindowInsetsCompat build()

Builds a WindowInsetsCompat instance.

setDisplayCutout

Added in 1.3.0
public @NonNull WindowInsetsCompat.Builder setDisplayCutout(@Nullable DisplayCutoutCompat displayCutout)

Sets the display cutout.

The cutout passed will only take effect when running on API 29 and above.

Parameters
@Nullable DisplayCutoutCompat displayCutout

the display cutout or null if there is none

See also
getDisplayCutout

setInsets

Added in 1.5.0
public @NonNull WindowInsetsCompat.Builder setInsets(int typeMask, @NonNull Insets insets)

Sets the insets of a specific window type in pixels.

The insets represents the area of a a window that is partially or fully obscured by the system windows identified by typeMask.

Parameters
int typeMask

The bitmask of Type to set the insets for.

@NonNull Insets insets

The insets to set.

See also
getInsets

setInsetsIgnoringVisibility

Added in 1.5.0
public @NonNull WindowInsetsCompat.Builder setInsetsIgnoringVisibility(int typeMask, @NonNull Insets insets)

Sets the insets a specific window type in pixels, while ignoring its visibility state.

The insets represents the area of a a window that that may be partially or fully obscured by the system window identified by typeMask. 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 inset returned here will still provide the inset associated with the status bar being shown.

Parameters
int typeMask

The bitmask of Type to set the insets for.

@NonNull Insets insets

The insets to set.

Throws
java.lang.IllegalArgumentException

If typeMask contains ime. Maximum insets are not available for this type as the height of the IME is dynamic depending on the EditorInfo of the currently focused view, as well as the UI state of the IME.

setMandatorySystemGestureInsets

Added in 1.3.0
Deprecated in 1.5.0
public @NonNull WindowInsetsCompat.Builder setMandatorySystemGestureInsets(@NonNull 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 overridden by setSystemGestureExclusionRects.

The insets passed will only take effect when running on API 29 and above.

setStableInsets

Added in 1.3.0
Deprecated in 1.5.0
public @NonNull WindowInsetsCompat.Builder setStableInsets(@NonNull Insets insets)

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.

The insets passed will only take effect when running on API 29 and above.

See also
getStableInsets

setSystemGestureInsets

Added in 1.3.0
Deprecated in 1.5.0
public @NonNull WindowInsetsCompat.Builder setSystemGestureInsets(@NonNull 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.

The insets passed will only take effect when running on API 29 and above.

setSystemWindowInsets

Added in 1.3.0
Deprecated in 1.5.0
public @NonNull WindowInsetsCompat.Builder setSystemWindowInsets(@NonNull Insets insets)

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.

setTappableElementInsets

Added in 1.3.0
Deprecated in 1.5.0
public @NonNull WindowInsetsCompat.Builder setTappableElementInsets(@NonNull 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.

The insets passed will only take effect when running on API 29 and above.

setVisible

Added in 1.5.0
public @NonNull WindowInsetsCompat.Builder setVisible(int typeMask, boolean visible)

Sets whether windows that can cause insets are currently visible on screen.

Parameters
int typeMask

The bitmask of Type to set the visibility for.

boolean visible

Whether to mark the windows as visible or not.

See also
isVisible