Android 12 Developer Preview is here! Try it out, and give us your feedback!

Builder

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

Builder for WindowInsetsCompat.

Summary

Public constructors

Creates a builder where all insets are initially consumed.

<init>(@NonNull insets: WindowInsetsCompat)

Creates a builder where all insets are initialized from WindowInsetsCompat.

Public methods
WindowInsetsCompat

Builds a WindowInsetsCompat instance.

WindowInsetsCompat.Builder
setDisplayCutout(@Nullable displayCutout: DisplayCutoutCompat?)

Sets the display cutout.

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

Sets the insets of a specific window type in pixels.

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

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

WindowInsetsCompat.Builder

Sets mandatory system gesture insets in pixels.

WindowInsetsCompat.Builder
setStableInsets(@NonNull insets: Insets)

Sets the stable insets in pixels.

WindowInsetsCompat.Builder
setSystemGestureInsets(@NonNull insets: Insets)

Sets system gesture insets in pixels.

WindowInsetsCompat.Builder
setSystemWindowInsets(@NonNull insets: Insets)

Sets system window insets in pixels.

WindowInsetsCompat.Builder
setTappableElementInsets(@NonNull insets: Insets)

Sets tappable element insets in pixels.

WindowInsetsCompat.Builder
setVisible(typeMask: Int, visible: Boolean)

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

Public constructors

<init>

Builder()

Creates a builder where all insets are initially consumed.

<init>

Builder(@NonNull insets: WindowInsetsCompat)

Creates a builder where all insets are initialized from WindowInsetsCompat.

Parameters
insets WindowInsetsCompat: the instance to initialize from.

Public methods

build

@NonNull fun build(): WindowInsetsCompat

Builds a WindowInsetsCompat instance.

Return
WindowInsetsCompat the WindowInsetsCompat instance.

setDisplayCutout

@NonNull fun setDisplayCutout(@Nullable displayCutout: DisplayCutoutCompat?): WindowInsetsCompat.Builder

Sets the display cutout.

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

Parameters
displayCutout DisplayCutoutCompat?: the display cutout or null if there is none
Return
WindowInsetsCompat.Builder itself

setInsets

@NonNull fun setInsets(
    typeMask: Int,
    @NonNull insets: Insets
): WindowInsetsCompat.Builder

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
typeMask Int: The bitmask of Type to set the insets for.
insets Insets: The insets to set.
Return
WindowInsetsCompat.Builder itself

See Also

setInsetsIgnoringVisibility

@NonNull fun setInsetsIgnoringVisibility(
    typeMask: Int,
    @NonNull insets: Insets
): WindowInsetsCompat.Builder

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
typeMask Int: The bitmask of Type to set the insets for.
insets Insets: The insets to set.
Return
WindowInsetsCompat.Builder itself
Exceptions
IllegalArgumentException If typeMask contains Type#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

@NonNull fun setMandatorySystemGestureInsets(@NonNull insets: Insets)