WindowCompat
class WindowCompat
kotlin.Any | |
↳ | androidx.core.view.WindowCompat |
Helper for accessing features in Window
.
Summary
Constants | |
---|---|
static Int |
Flag for enabling the Action Bar. |
static Int |
Flag for requesting an Action Bar that overlays window content. |
static Int |
Flag for specifying the behavior of action modes when an Action Bar is not present. |
Public methods | |
---|---|
static WindowInsetsControllerCompat? |
getInsetsController(@NonNull window: Window, @NonNull view: View) Retrieves the single |
static T |
requireViewById(@NonNull window: Window, @IdRes id: Int) Finds a view that was identified by the |
static Unit |
setDecorFitsSystemWindows(@NonNull window: Window, decorFitsSystemWindows: Boolean) Sets whether the decor view should fit root-level content views for |
Constants
FEATURE_ACTION_BAR
static val FEATURE_ACTION_BAR: Int
Flag for enabling the Action Bar. This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.
Value: 8
FEATURE_ACTION_BAR_OVERLAY
static val FEATURE_ACTION_BAR_OVERLAY: Int
Flag for requesting an Action Bar that overlays window content. Normally an Action Bar will sit in the space above window content, but if this feature is requested along with FEATURE_ACTION_BAR
it will be layered over the window content itself. This is useful if you would like your app to have more control over how the Action Bar is displayed, such as letting application content scroll beneath an Action Bar with a transparent background or otherwise displaying a transparent/translucent Action Bar over application content.
This mode is especially useful with View.SYSTEM_UI_FLAG_FULLSCREEN
, which allows you to seamlessly hide the action bar in conjunction with other screen decorations.
As of android.os.Build.VERSION_CODES#JELLY_BEAN
, when an ActionBar is in this mode it will adjust the insets provided to View.fitSystemWindows(Rect)
to include the content covered by the action bar, so you can do layout within that space.
Value: 9
FEATURE_ACTION_MODE_OVERLAY
static val FEATURE_ACTION_MODE_OVERLAY: Int
Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.
Value: 10
Public methods
getInsetsController
@Nullable static fun getInsetsController(
@NonNull window: Window,
@NonNull view: View
): WindowInsetsControllerCompat?
Retrieves the single WindowInsetsController
of the window this view is attached to.
Return | |
---|---|
WindowInsetsControllerCompat? |
The WindowInsetsController or null if the view is neither attached to a window nor a view tree with a decor. |
See Also
requireViewById
@NonNull static fun <T : View!> requireViewById(
@NonNull window: Window,
@IdRes id: Int
): T
Finds a view that was identified by the android:id
XML attribute that was processed in android.app.Activity#onCreate, or throws an IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.
Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.
Parameters | |
---|---|
id |
Int: the ID to search for |
Return | |
---|---|
T |
a view with given ID |
setDecorFitsSystemWindows
static fun setDecorFitsSystemWindows(
@NonNull window: Window,
decorFitsSystemWindows: Boolean
): Unit
Sets whether the decor view should fit root-level content views for WindowInsetsCompat
.
If set to false
, the framework will not fit the content view to the insets and will just pass through the WindowInsetsCompat
to the content view.
Please note: using the View#setSystemUiVisibility(int)
API in your app can conflict with this method. Please discontinue use of View#setSystemUiVisibility(int)
.
Parameters | |
---|---|
window |
Window: The current window. |
decorFitsSystemWindows |
Boolean: Whether the decor view should fit root-level content views for insets. |