Package 

Class WindowInsetsCompat


  • 
    public class 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.

    • Constructor Detail

      • WindowInsetsCompat

        WindowInsetsCompat(WindowInsetsCompat src)
        Constructs a new WindowInsetsCompat, copying all values from a source WindowInsetsCompat.
        Parameters:
        src - source from which values are copied
    • Method Detail

      • getSystemWindowInsetLeft

        @Deprecated() int getSystemWindowInsetLeft()

        Returns the left system window inset in pixels.

        The system window inset represents the area of a full-screen window that ispartially 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 {@code 0}.

      • getSystemWindowInsetTop

        @Deprecated() int getSystemWindowInsetTop()

        Returns the top system window inset in pixels.

        The system window inset represents the area of a full-screen window that ispartially 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 {@code 0}.

      • getSystemWindowInsetRight

        @Deprecated() int getSystemWindowInsetRight()

        Returns the right system window inset in pixels.

        The system window inset represents the area of a full-screen window that ispartially 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 {@code 0}.

      • getSystemWindowInsetBottom

        @Deprecated() int getSystemWindowInsetBottom()

        Returns the bottom system window inset in pixels.

        The system window inset represents the area of a full-screen window that ispartially 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 {@code 0}.

      • hasSystemWindowInsets

        @Deprecated() boolean hasSystemWindowInsets()

        Returns true if this WindowInsets has nonzero system window insets.

        The system window inset represents the area of a full-screen window that ispartially 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 {@code false}.

      • hasInsets

         boolean hasInsets()

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

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

      • isConsumed

         boolean isConsumed()

        Check if these insets have been fully consumed.

        Insets are considered "consumed" if the applicable consume* methodshave been called such that all insets have been set to zero. This affects propagation ofinsets through the view hierarchy; insets that have not been fully consumed will continueto propagate down to child views.

        The result of this method is equivalent to the return value of fitSystemWindows.

      • isRound

         boolean isRound()

        Returns true if the associated window has a round shape.

        A round window's left, top, right and bottom edges reach all the way to theassociated edges of the window but the corners may not be visible. Views respondingto round insets should take care to not lay out critical elements within the cornerswhere they may not be accessible.

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

      • replaceSystemWindowInsets

        @Deprecated()@NonNull() WindowInsetsCompat replaceSystemWindowInsets(int left, int top, int right, int bottom)

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

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

        Parameters:
        left - New left inset in pixels
        top - New top inset in pixels
        right - New right inset in pixels
        bottom - New bottom inset in pixels
      • replaceSystemWindowInsets

        @Deprecated()@NonNull() WindowInsetsCompat replaceSystemWindowInsets(@NonNull() Rect systemWindowInsets)

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

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

        Parameters:
        systemWindowInsets - New system window insets.
      • getStableInsetTop

        @Deprecated() int getStableInsetTop()

        Returns the top stable inset in pixels.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

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

      • getStableInsetLeft

        @Deprecated() int getStableInsetLeft()

        Returns the left stable inset in pixels.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

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

      • getStableInsetRight

        @Deprecated() int getStableInsetRight()

        Returns the right stable inset in pixels.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

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

      • getStableInsetBottom

        @Deprecated() int getStableInsetBottom()

        Returns the bottom stable inset in pixels.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

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

      • hasStableInsets

        @Deprecated() boolean hasStableInsets()

        Returns true if this WindowInsets has nonzero stable insets.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

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

      • getSystemWindowInsets

        @Deprecated()@NonNull() Insets getSystemWindowInsets()

        Returns the system window insets in pixels.

        The system window inset represents the area of a full-screen window that ispartially or fully obscured by the status bar, navigation bar, IME or other system windows.

      • getStableInsets

        @Deprecated()@NonNull() Insets getStableInsets()

        Returns the stable insets in pixels.

        The stable inset represents the area of a full-screen window that may bepartially or fully obscured by the system UI elements. This value does not changebased on the visibility state of those elements; for example, if the status bar isnormally shown, but temporarily hidden, the stable inset will still provide the insetassociated with the status bar being shown.

      • getMandatorySystemGestureInsets

        @Deprecated()@NonNull() Insets getMandatorySystemGestureInsets()

        Returns the mandatory system gesture insets.

        The mandatory system gesture insets represent the area of a window where mandatory systemgestures have priority and may consume some or all touch input, e.g. due to the a system baroccupying it, or it being reserved for touch-only gestures.

      • getTappableElementInsets

        @Deprecated()@NonNull() Insets getTappableElementInsets()

        Returns the tappable element insets.

        The tappable element insets represent how much tappable elements must at least beinset to remain both tappable and visually unobstructed by persistent system windows.

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

      • inset

        @NonNull() WindowInsetsCompat inset(@NonNull() Insets insets)

        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 thecurrent area.

        Example:

        childView.dispatchApplyWindowInsets(insets.inset(childMargins));
        
        Parameters:
        insets - the amount of insets to remove from all sides.
      • inset

        @NonNull() WindowInsetsCompat inset(int left, int top, int right, int bottom)

        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 thecurrent area.

        Example:

        childView.dispatchApplyWindowInsets(insets.inset(
                childMarginLeft, childMarginTop, childMarginBottom, childMarginRight));
        
        Parameters:
        left - the amount of insets to remove from the left.
        top - the amount of insets to remove from the top.
        right - the amount of insets to remove from the right.
        bottom - the amount of insets to remove from the bottom.
      • getInsets

        @NonNull() Insets getInsets(int typeMask)

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

        Parameters:
        typeMask - Bit mask of Types to query the insets for.
      • getInsetsIgnoringVisibility

        @NonNull() Insets getInsetsIgnoringVisibility(int typeMask)

        Returns the insets a specific set of windows can cause, denoted by the {@code typeMask} bit mask of Types, regardless of whether that type iscurrently visible or not.

        The insets represents the area of a a window that that may be partiallyor fully obscured by the system window identified by {@code typeMask}. This value does notchange based on the visibility state of those elements. For example, if the status bar isnormally shown, but temporarily hidden, the inset returned here will still provide the insetassociated with the status bar being shown.

        When running on devices with API Level 29 and before, the returned insets are anapproximation based on the information available. This is especially true for the IME type, which currently only works when running on devices with SDK level 23and above.
        Parameters:
        typeMask - Bit mask of Types to query the insets for.
      • isVisible

         boolean isVisible(int typeMask)

        Returns whether a set of windows that may cause insets is currently visible on screen,regardless of whether it actually overlaps with this window.When running on devices with API Level 29 and before, the returned value is anapproximation based on the information available. This is especially true for the IME type, which currently only works when running on devices with SDK level 23and above.

        Parameters:
        typeMask - Bit mask of Types to query visibility status.