Added in API level 30

WindowInsets.Type


public static final class WindowInsets.Type
extends Object

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


Class that defines different types of sources causing window insets.

Each type is represented by an integer bit flag. Types can be combined using bitwise OR (e.g. Type.statusBars() | Type.navigationBars()) and passed to query methods such as WindowInsets.getInsets(int), WindowInsets.getInsetsIgnoringVisibility(int), WindowInsets.isVisible(int), WindowInsets.getBoundingRects(int), or to WindowInsetsController methods to request showing or hiding system elements.

Summary

Public methods

static int captionBar()

Returns an insets type representing the window of a caption bar.

static int displayCutout()

Returns an insets type representing the area that used by DisplayCutout.

static int ime()

Returns an insets type representing the window of an on-screen Input Method Editor (IME).

static int mandatorySystemGestures()

Returns an insets type representing the mandatory system gesture insets.

static int navigationBars()

Returns an insets type representing any system bars for navigation.

static int statusBars()

Returns an insets type representing any system bars displaying device status.

static int systemBars()

Returns an aggregate insets type representing all system bars and persistent system decorations.

static int systemGestures()

Returns an insets type representing the system gesture insets.

static int systemOverlays()

Returns an insets type representing persistent, non-dismissible system overlays.

static int tappableElement()

Returns an insets type representing the tappable element insets.

Inherited methods

Public methods

captionBar

Added in API level 30
public static int captionBar ()

Returns an insets type representing the window of a caption bar.

A caption bar represents the window header / title bar provided by the system for window decorations and management controls (such as minimize, maximize/restore, close, and title text).

Applications targeting desktop environments can use this inset alongside WindowInsets.getBoundingRects(int) to draw custom header content without colliding with system window control buttons.

Returns
int An insets type representing the window of a caption bar.
Value is either 0 or a combination of the following:

displayCutout

Added in API level 30
public static int displayCutout ()

Returns an insets type representing the area that used by DisplayCutout.

This is equivalent to the safe insets on WindowInsets.getDisplayCutout().

Note: During dispatch to View.onApplyWindowInsets, if the window is using the default WindowManager.LayoutParams.layoutInDisplayCutoutMode, WindowInsets.getDisplayCutout() will return null even if the window overlaps a display cutout area, in which case the displayCutout() inset will still report the accurate value.

Returns
int Value is either 0 or a combination of the following:

ime

Added in API level 30
public static int ime ()

Returns an insets type representing the window of an on-screen Input Method Editor (IME).

The IME inset represents the area occupied by the on-screen software keyboard when requested by an active text input field.

Floating & Undocked IMEs: When the on-screen keyboard is configured in floating or undocked mode (such as on tablets, foldables, desktop environments, or when selected by the user), it floats above window content without docking to a screen edge. In floating mode, the keyboard does not produce window insets, and querying WindowInsets.getInsets(int) with ime() will return Insets.NONE (even while the keyboard is visible). Applications should note that floating keyboards may occlude underlying UI elements without causing the view hierarchy to inset or resize.

Note: WindowInsets.getInsetsIgnoringVisibility(int) cannot be queried for ime() because the height of the IME is determined dynamically by the focused view's EditorInfo and the IME state; attempting to do so will throw an IllegalArgumentException.

Returns
int Value is either 0 or a combination of the following:

mandatorySystemGestures

Added in API level 30
public static int mandatorySystemGestures ()

Returns an insets type representing the mandatory system gesture insets.

Mandatory system gesture insets represent the areas of a window where system gestures are critical and cannot be overridden or opted out of by the application using View.setSystemGestureExclusionRects(List).

Returns
int Value is either 0 or a combination of the following:

Added in API level 30
public static int navigationBars ()

Returns an insets type representing any system bars for navigation.

Navigation bars provide affordances for the user to navigate to other screens or activities.

These insets can be controlled dynamically via WindowInsetsController APIs.

Returns
int Value is either 0 or a combination of the following:

statusBars

Added in API level 30
public static int statusBars ()

Returns an insets type representing any system bars displaying device status.

Status bars typically display persistent indicators such as the clock, battery level, signal strength, and notification icons.

This type of insets can be controlled dynamically via WindowInsetsController APIs.

Returns
int Value is either 0 or a combination of the following:

systemBars

Added in API level 30
public static int systemBars ()

Returns an aggregate insets type representing all system bars and persistent system decorations.

Includes statusBars(), navigationBars(), captionBar(), and systemOverlays(), but excludes ime() and displayCutout().

Returns
int Value is either 0 or a combination of the following:

systemGestures

Added in API level 30
public static int systemGestures ()

Returns an insets type representing the system gesture insets.

The system gesture insets represent the area of a window where system gestures (such as the edge-swipe back gesture or bottom-swipe home gesture) have priority and may consume touch input before it reaches the window.

Simple taps are guaranteed to reach the window even within the system gesture insets, as long as they are outside the areas reported by system window insets.

Apps can declare priority over non-mandatory system gestures in specific sub-regions using View.setSystemGestureExclusionRects(List).

Returns
int Value is either 0 or a combination of the following:

systemOverlays

Added in API level 34
public static int systemOverlays ()

Returns an insets type representing persistent, non-dismissible system overlays.

System overlays represent insets caused by system-provided UI elements overlaid on the screen or window that cannot be hidden or controlled by client WindowInsetsController requests.

For compatibility reasons, this type is included in systemBars(), ensuring views that fit systemBars() automatically accommodate system overlays.

Returns
int Value is either 0 or a combination of the following:

See also:

tappableElement

Added in API level 30
public static int tappableElement ()

Returns an insets type representing the tappable element insets.

Apps should inset its tappable elements by at least this amount to ensure they can be tapped.

This inset is always at most the size of systemBars(). It may be smaller than the systemBars() inset if the system bars let through clean taps but not other kinds of gestures.

Returns
int Value is either 0 or a combination of the following: