There are different ways to display the fullscreen (without System bar or behind the System Bar)
- Without System bar
- Behind the System Bar
To Hide systemBars
WindowInsetsControllerCompat(window, window.decorView) windowInsets.hide(WindowInsetsCompat.Type.systemBars()) windowInsets.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPEImmersive.mov
Use setDecorFitsSystemWindows (Edge-To-Edge)
WindowCompat .setDecorFitsSystemWindows( window, false ) edge-to-edge.mov
[Update] Application targets SDK is 35 or later
Use enableEdgeToEdge() automatically support edge-to-edge and handle the color of the system bars.
enableEdgeToEdge()Return CONSUMED from WindowInsetsListener
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, _ -> WindowInsetsCompat.CONSUMED } To reset
ViewCompat.setOnApplyWindowInsetsListener(window.decorView, null) app:layout_behavior="@string/appbar_scrolling_view_behavior"<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- Need for scrolling view behaviour --> <com.google.android.material.appbar.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/black" android:fitsSystemWindows="true" android:visibility="gone"/> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <!-- Add your layout --> </FrameLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>Set transperant statusbar
window.statusBarColor = Color.TRANSPARENT Window insets: is the area you display your screen
To get insets
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())To change of the window insets for a view
setOnApplyWindowInsetsListener
window_insets.mov
The system bars: the status bar and the navigation bar
Hide system bar
WindowInsetsControllerCompat( window, window.decorView ).hide(WindowInsetsCompat.Type.systemBars())Show system bar
WindowInsetsControllerCompat( window, window.decorView ).show(WindowInsetsCompat.Type.systemBars())To control the visibility to one of system bars
Replace
WindowInsetsCompat.Type.systemBars() With
WindowInsetsCompat.Type.navigationBars() Or WindowInsetsCompat.Type.statusBars()

