Skip to content

sallySalem/FullScreen

Repository files navigation

FullScreen

There are different ways to display the fullscreen (without System bar or behind the System Bar)

Fullscreen without systembar

Immsersive mode

To Hide systemBars

WindowInsetsControllerCompat(window, window.decorView) windowInsets.hide(WindowInsetsCompat.Type.systemBars()) windowInsets.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
Immersive.mov


Fullscreen behind the System Bar

Edge-To-Edge

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()

WindowInsetsListener

Return CONSUMED from WindowInsetsListener

 ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, _ -> WindowInsetsCompat.CONSUMED } 

To reset

 ViewCompat.setOnApplyWindowInsetsListener(window.decorView, null) 







Layout behavior using CoordinatorLayout

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

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 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()

About

Show different cases to display fullscreen in android

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages