-
public final class WindowInsetsControllerCompat
Provide simple controls of windows that generate insets. For SDKs >= 30, this class is a simple wrapper around WindowInsetsController. For lower SDKs, this class aims to behave as close as possible to the original implementation.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
BEHAVIOR_SHOW_BARS_BY_TOUCH
public final static int
BEHAVIOR_SHOW_BARS_BY_SWIPE
public final static int
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
-
Constructor Summary
Constructors Constructor Description WindowInsetsControllerCompat(Window window, View view)
-
Method Summary
Modifier and Type Method Description static WindowInsetsControllerCompat
toWindowInsetsControllerCompat(@NonNull() WindowInsetsController insetsController)
Wrap a WindowInsetsController into a WindowInsetsControllerCompat forcompatibility purpose. void
show(int types)
Makes a set of windows that cause insets appear on screen. void
hide(int types)
Makes a set of windows causing insets disappear. boolean
isAppearanceLightStatusBars()
Checks if the foreground of the status bar is set to light. void
setAppearanceLightStatusBars(boolean isLight)
If true, changes the foreground color of the status bars to light so that the items on thebar can be read clearly. boolean
isAppearanceLightNavigationBars()
Checks if the foreground of the navigation bar is set to light. void
setAppearanceLightNavigationBars(boolean isLight)
If true, changes the foreground color of the navigation bars to light so that the items onthe bar can be read clearly. void
setSystemBarsBehavior(int behavior)
Controls the behavior of system bars. int
getSystemBarsBehavior()
Retrieves the requested behavior of system bars. -
-
Method Detail
-
toWindowInsetsControllerCompat
@NonNull() static WindowInsetsControllerCompat toWindowInsetsControllerCompat(@NonNull() WindowInsetsController insetsController)
Wrap a WindowInsetsController into a WindowInsetsControllerCompat forcompatibility purpose.
- Parameters:
insetsController
- The WindowInsetsController to wrap.
-
show
void show(int types)
Makes a set of windows that cause insets appear on screen.
Note that if the window currently doesn't have control over a certain type, it will apply thechange as soon as the window gains control. The app can listen to the event by observing onApplyWindowInsets and checking visibility with isVisible.
- Parameters:
types
- A bitmask of WindowInsetsCompat.Type specifying what windows the appwould like to make appear on screen.
-
hide
void hide(int types)
Makes a set of windows causing insets disappear.
Note that if the window currently doesn't have control over a certain type, it will apply thechange as soon as the window gains control. The app can listen to the event by observing onApplyWindowInsets and checking visibility with isVisible.
- Parameters:
types
- A bitmask of WindowInsetsCompat.Type specifying what windows the appwould like to make disappear.
-
isAppearanceLightStatusBars
boolean isAppearanceLightStatusBars()
Checks if the foreground of the status bar is set to light.
This method always returns false on API < 23.
-
setAppearanceLightStatusBars
void setAppearanceLightStatusBars(boolean isLight)
If true, changes the foreground color of the status bars to light so that the items on thebar can be read clearly. If false, reverts to the default appearance.
This method has no effect on API < 23.
-
isAppearanceLightNavigationBars
boolean isAppearanceLightNavigationBars()
Checks if the foreground of the navigation bar is set to light.
This method always returns false on API < 26.
-
setAppearanceLightNavigationBars
void setAppearanceLightNavigationBars(boolean isLight)
If true, changes the foreground color of the navigation bars to light so that the items onthe bar can be read clearly. If false, reverts to the default appearance.
This method has no effect on API < 26.
-
setSystemBarsBehavior
void setSystemBarsBehavior(int behavior)
Controls the behavior of system bars.
- Parameters:
behavior
- Determines how the bars behave when being hidden by the application.
-
getSystemBarsBehavior
int getSystemBarsBehavior()
Retrieves the requested behavior of system bars.
-
-
-
-