# Print output for @column tags ?> WindowInsets.Builder - Android SDK | Android Developers

Most visited

Recently visited

WindowInsets.Builder

public static final class WindowInsets.Builder
extends Object

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


Builder for WindowInsets.

Summary

Public constructors

Builder()

Creates a builder where all insets are initially consumed.

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 setInsets(int typeMask, Insets insets)

Sets the insets of a specific window type in pixels.

WindowInsets.Builder setInsetsIgnoringVisibility(int typeMask, Insets insets)

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

WindowInsets.Builder setMandatorySystemGestureInsets(Insets insets)

This method is deprecated. Use setInsets(int, android.graphics.Insets) with Type#mandatorySystemGestures().

WindowInsets.Builder setPrivacyIndicatorBounds(Rect bounds)

Sets the bounds of the system privacy indicator.

WindowInsets.Builder setRoundedCorner(int position, RoundedCorner roundedCorner)

Sets the rounded corner of given position.

WindowInsets.Builder setStableInsets(Insets stableInsets)

This method is deprecated. Use setInsetsIgnoringVisibility(int, android.graphics.Insets) with Type#systemBars().

WindowInsets.Builder setSystemGestureInsets(Insets insets)

This method is deprecated. Use setInsets(int, android.graphics.Insets) with Type#systemGestures().

WindowInsets.Builder setSystemWindowInsets(Insets systemWindowInsets)

This method is deprecated. Use setInsets(int, android.graphics.Insets) with Type#systemBars().

WindowInsets.Builder setTappableElementInsets(Insets insets)

This method is deprecated. Use setInsets(int, android.graphics.Insets) with Type#tappableElement().

WindowInsets.Builder setVisible(int typeMask, boolean visible)

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

Inherited methods

Public constructors

Builder

public Builder ()

Creates a builder where all insets are initially consumed.

Builder

public Builder (WindowInsets insets)

Creates a builder where all insets are initialized from WindowInsets.

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

Public methods

build

public WindowInsets build ()

Builds a WindowInsets instance.

Returns
WindowInsets the WindowInsets instance. This value cannot be null.

setDisplayCutout

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

See also:

setInsets

public WindowInsets.Builder setInsets (int typeMask, 
                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
typeMask int: The bitmask of Type to set the insets for. Value is either 0 or a combination of android.view.WindowInsets.Type.STATUS_BARS, android.view.WindowInsets.Type.NAVIGATION_BARS, android.view.WindowInsets.Type.CAPTION_BAR, android.view.WindowInsets.Type.IME, android.view.WindowInsets.Type.WINDOW_DECOR, android.view.WindowInsets.Type.SYSTEM_GESTURES, android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES, android.view.WindowInsets.Type.TAPPABLE_ELEMENT, and android.view.WindowInsets.Type.DISPLAY_CUTOUT

insets Insets: The insets to set. This value cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setInsetsIgnoringVisibility

public WindowInsets.Builder setInsetsIgnoringVisibility (int typeMask, 
                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 type. 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. Value is either 0 or a combination of android.view.WindowInsets.Type.STATUS_BARS, android.view.WindowInsets.Type.NAVIGATION_BARS, android.view.WindowInsets.Type.CAPTION_BAR, android.view.WindowInsets.Type.IME, android.view.WindowInsets.Type.WINDOW_DECOR, android.view.WindowInsets.Type.SYSTEM_GESTURES, android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES, android.view.WindowInsets.Type.TAPPABLE_ELEMENT, and android.view.WindowInsets.Type.DISPLAY_CUTOUT

insets Insets: The insets to set. This value cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

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

See also:

setMandatorySystemGestureInsets

public WindowInsets.Builder setMandatorySystemGestureInsets (Insets insets)

This method is deprecated.
Use setInsets(int, android.graphics.Insets) with Type#mandatorySystemGestures().

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 cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setPrivacyIndicatorBounds

public WindowInsets.Builder setPrivacyIndicatorBounds (Rect bounds)

Sets the bounds of the system privacy indicator.

Parameters
bounds Rect: The bounds of the system privacy indicator This value may be null.

Returns
WindowInsets.Builder This value cannot be null.

setRoundedCorner

public WindowInsets.Builder setRoundedCorner (int position, 
                RoundedCorner roundedCorner)

Sets the rounded corner of given position.

Parameters
position int: the position of this rounded corner Value is RoundedCorner.POSITION_TOP_LEFT, RoundedCorner.POSITION_TOP_RIGHT, RoundedCorner.POSITION_BOTTOM_RIGHT, or RoundedCorner.POSITION_BOTTOM_LEFT

roundedCorner RoundedCorner: the rounded corner or null if there is none This value may be null.

Returns
WindowInsets.Builder itself

See also:

setStableInsets

public WindowInsets.Builder setStableInsets (Insets stableInsets)

This method is deprecated.
Use setInsetsIgnoringVisibility(int, android.graphics.Insets) with Type#systemBars().

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 cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setSystemGestureInsets

public WindowInsets.Builder setSystemGestureInsets (Insets insets)

This method is deprecated.
Use setInsets(int, android.graphics.Insets) with Type#systemGestures().

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 cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setSystemWindowInsets

public WindowInsets.Builder setSystemWindowInsets (Insets systemWindowInsets)

This method is deprecated.
Use setInsets(int, android.graphics.Insets) with Type#systemBars().

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 cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setTappableElementInsets

public WindowInsets.Builder setTappableElementInsets (Insets insets)

This method is deprecated.
Use setInsets(int, android.graphics.Insets) with Type#tappableElement().

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 cannot be null.

Returns
WindowInsets.Builder itself This value cannot be null.

See also:

setVisible

public WindowInsets.Builder setVisible (int typeMask, 
                boolean visible)

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

Parameters
typeMask int: The bitmask of Type to set the visibility for. Value is either 0 or a combination of android.view.WindowInsets.Type.STATUS_BARS, android.view.WindowInsets.Type.NAVIGATION_BARS, android.view.WindowInsets.Type.CAPTION_BAR, android.view.WindowInsets.Type.IME, android.view.WindowInsets.Type.WINDOW_DECOR, android.view.WindowInsets.Type.SYSTEM_GESTURES, android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES, android.view.WindowInsets.Type.TAPPABLE_ELEMENT, and android.view.WindowInsets.Type.DISPLAY_CUTOUT

visible boolean: Whether to mark the windows as visible or not.

Returns
WindowInsets.Builder itself This value cannot be null.

See also: