Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

WindowInsetsCompat

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

Describes a set of insets for window content.

WindowInsetsCompats are immutable and may be expanded to include more inset types in the future. To adjust insets, use one of the supplied clone methods to obtain a new WindowInsetsCompat instance with the adjusted properties.

Summary

Nested classes

Builder for WindowInsetsCompat.

Class that defines different types of sources causing window insets.

Public constructors
<init>(@Nullable src: WindowInsetsCompat?)

Constructs a new WindowInsetsCompat, copying all values from a source WindowInsetsCompat.

Public methods
open WindowInsetsCompat

Returns a copy of this WindowInsets with the cutout fully consumed.

open WindowInsetsCompat

Returns a copy of this WindowInsets with the stable insets fully consumed.

open WindowInsetsCompat

Returns a copy of this WindowInsets with the system window insets fully consumed.

open Boolean
equals(other: Any?)

open DisplayCutoutCompat?

Returns the display cutout if there is one.

open Insets
getInsets(typeMask: Int)

Returns the insets of a specific set of windows causing insets, denoted by the typeMask bit mask of Types.

open Insets

Returns the insets a specific set of windows can cause, denoted by the typeMask bit mask of Types, regardless of whether that type is currently visible or not.

open Insets

Returns the mandatory system gesture insets.

open Int

Returns the bottom stable inset in pixels.

open Int

Returns the left stable inset in pixels.

open Int

Returns the right stable inset in pixels.

open Int

Returns the top stable inset in pixels.

open Insets

Returns the stable insets in pixels.

open Insets

Returns the system gesture insets.

open Int

Returns the bottom system window inset in pixels.

open Int

Returns the left system window inset in pixels.

open Int

Returns the right system window inset in pixels.

open Int

Returns the top system window inset in pixels.

open Insets

Returns the system window insets in pixels.

open Insets

Returns the tappable element insets.

open Boolean

Returns true if this WindowInsets has any non-zero insets.

open Boolean

Returns true if this WindowInsets has nonzero stable insets.

open Boolean

Returns true if this WindowInsets has nonzero system window insets.

open Int

open WindowInsetsCompat
inset(@NonNull insets: Insets)

Returns a copy of this instance inset in the given directions.

open WindowInsetsCompat
inset(@IntRange(0) left: Int, @IntRange(0) top: Int, @IntRange(0) right: Int, @IntRange(0) bottom: Int)

Returns a copy of this instance inset in the given directions.

open Boolean

Check if these insets have been fully consumed.

open Boolean

Returns true if the associated window has a round shape.

open Boolean
isVisible(typeMask: Int)

Returns whether a set of windows that may cause insets is currently visible on screen, regardless of whether it actually overlaps with this window.

open WindowInsetsCompat
replaceSystemWindowInsets(left: Int, top: Int, right: Int, bottom: Int)

Returns a copy of this WindowInsets with selected system window insets replaced with new values.

open WindowInsetsCompat
replaceSystemWindowInsets(@NonNull systemWindowInsets: Rect)

Returns a copy of this WindowInsets with selected system window insets replaced with new values.

open WindowInsets?

Return the source WindowInsets instance used in this WindowInsetsCompat.

open static WindowInsetsCompat

Wrap an instance of WindowInsets into a WindowInsetsCompat.

open static WindowInsetsCompat
toWindowInsetsCompat(@NonNull insets: WindowInsets, @Nullable view: View?)

Wrap an instance of WindowInsets into a WindowInsetsCompat.

Properties
static WindowInsetsCompat

A WindowInsetsCompat instance for which isConsumed() returns true.

Public constructors

<init>

WindowInsetsCompat(@Nullable src: WindowInsetsCompat?)

Constructs a new WindowInsetsCompat, copying all values from a source WindowInsetsCompat.

Parameters
src WindowInsetsCompat?: source from which values are copied

Public methods

consumeDisplayCutout

@NonNull open fun consumeDisplayCutout(): WindowInsetsCompat

Deprecated: Consuming of different parts individually of a WindowInsetsCompat instance is deprecated, since WindowInsetsCompat contains many different insets. Use CONSUMED instead to stop dispatching insets.

Returns a copy of this WindowInsets with the cutout fully consumed.

When running on platforms with API 27 and below, this method is a no-op.

Return
WindowInsetsCompat A modified copy of this WindowInsets

consumeStableInsets

@NonNull open fun consumeStableInsets(): WindowInsetsCompat

Deprecated: Consuming of different parts individually of a WindowInsetsCompat instance is deprecated, since WindowInsetsCompat contains many different insets. Use CONSUMED instead to stop dispatching insets.

Returns a copy of this WindowInsets with the stable insets fully consumed.

When running on platforms with API 20 and below, this method always returns null.

Return
WindowInsetsCompat A modified copy of this WindowInsetsCompat

consumeSystemWindowInsets

@NonNull open fun consumeSystemWindowInsets(): WindowInsetsCompat

Deprecated: Consuming of different parts individually of a WindowInsetsCompat instance is deprecated, since WindowInsetsCompat contains many different insets. Use CONSUMED instead to stop dispatching insets.

Returns a copy of this WindowInsets with the system window insets fully consumed.

When running on platforms with API 19 and below, this method always returns null.

Return
WindowInsetsCompat A modified copy of this WindowInsets

equals

open fun equals(other: Any?): Boolean

getDisplayCutout

@Nullable open fun getDisplayCutout(): DisplayCutoutCompat?

Returns the display cutout if there is one.

When running on platforms with API 27 and below, this method always returns null.

Return
DisplayCutoutCompat? the display cutout or null if there is none

getInsets

@NonNull open fun getInsets(typeMask: Int): Insets

Returns the insets of a specific set of windows causing insets, denoted by the typeMask bit mask of Types. When running on devices with API Level 29 and before, the returned insets are an approximation based on the information available. This is especially true for the type, which currently only works when running on devices with SDK level 23 and above.

Parameters
typeMask Int: Bit mask of Types to query the insets for.
Return
Insets The insets.

getInsetsIgnoringVisibility

@NonNull open fun getInsetsIgnoringVisibility(typeMask: Int): Insets

Returns the insets a specific set of windows can cause, denoted by the typeMask bit mask of Types, regardless of whether that type is currently visible or not.

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.

When running on devices with API Level 29 and before, the returned insets are an approximation based on the information available. This is especially true for the type, which currently only works when running on devices with SDK level 23 and above.
Parameters
typeMask Int: Bit mask of Types to query the insets for.
Return
Insets The insets.
Exceptions
IllegalArgumentException If the caller tries to query Type#ime(). Insets are not available if the IME isn't visible 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.

getMandatorySystemGestureInsets

@NonNull open fun getMandatorySystemGestureInsets(): Insets

Deprecated: Use getInsets(int) with Type#mandatorySystemGestures() instead.

Returns the mandatory system gesture insets.

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.

getStableInsetBottom

open fun getStableInsetBottom(): Int

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

Returns the bottom stable inset 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.

When running on platforms with API 20 and below, this method always returns 0.

Return
Int The bottom stable inset

getStableInsetLeft

open fun getStableInsetLeft(): Int

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

Returns the left stable inset 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.

When running on platforms with API 20 and below, this method always returns 0.

Return
Int The left stable inset

getStableInsetRight

open fun getStableInsetRight(): Int

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

Returns the right stable inset 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.

When running on platforms with API 20 and below, this method always returns 0.

Return
Int The right stable inset

getStableInsetTop

open fun getStableInsetTop(): Int

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

Returns the top stable inset 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.

When running on platforms with API 20 and below, this method always returns 0.

getStableInsets

@NonNull open fun getStableInsets(): Insets

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

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

Return
Insets The stable insets

getSystemGestureInsets

@NonNull open fun getSystemGestureInsets(): Insets

Deprecated: Use getInsets(int) with Type#systemGestures() instead.

Returns the system gesture insets.

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.

An app can declare priority over system gestures with android.view.View#setSystemGestureExclusionRects outside of the mandatory system gesture insets.

getSystemWindowInsetBottom

open fun getSystemWindowInsetBottom(): Int

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns the bottom system window inset 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.

When running on platforms with API 19 and below, this method always returns 0.

Return
Int The bottom system window inset

getSystemWindowInsetLeft

open fun getSystemWindowInsetLeft(): Int

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns the left system window inset 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.

When running on platforms with API 19 and below, this method always returns 0.

Return
Int The left system window inset

getSystemWindowInsetRight

open fun getSystemWindowInsetRight(): Int

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns the right system window inset 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.

When running on platforms with API 19 and below, this method always returns 0.

Return
Int The right system window inset

getSystemWindowInsetTop

open fun getSystemWindowInsetTop(): Int

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns the top system window inset 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.

When running on platforms with API 19 and below, this method always returns 0.

Return
Int The top system window inset

getSystemWindowInsets

@NonNull open fun getSystemWindowInsets(): Insets

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns the 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.

Return
Insets The system window insets

getTappableElementInsets

@NonNull open fun getTappableElementInsets(): Insets

Deprecated: Use getInsets(int) with Type#tappableElement() instead.

Returns the tappable element insets.

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.

This may be smaller than getSystemWindowInsets() if the system window is largely transparent and lets through simple taps (but not necessarily more complex gestures).

hasInsets

open fun hasInsets(): Boolean

Returns true if this WindowInsets has any non-zero insets.

When running on platforms with API 19 and below, this method always returns false.

Return
Boolean true if any inset values are nonzero

hasStableInsets

open fun hasStableInsets(): Boolean

Deprecated: Use getInsetsIgnoringVisibility(int) with Type#systemBars() instead.

Returns true if this WindowInsets has nonzero stable insets.

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.

When running on platforms with API 20 and below, this method always returns false.

Return
Boolean true if any of the stable inset values are nonzero

hasSystemWindowInsets

open fun hasSystemWindowInsets(): Boolean

Deprecated: Use getInsets(int) with Type#systemBars() instead.

Returns true if this WindowInsets has nonzero system window insets.

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.

When running on platforms with API 19 and below, this method always returns false.

Return
Boolean true if any of the system window inset values are nonzero

hashCode

open fun hashCode(): Int

inset

@NonNull open fun inset(@NonNull insets: Insets): WindowInsetsCompat

Returns a copy of this instance inset in the given directions. This is intended for dispatching insets to areas of the window that are smaller than the current area.

Example:

childView.dispatchApplyWindowInsets(insets