Application with full screen mode in Jetpack Compose

919 views Asked by At

I'm currently building an application in jetpack compose which requires full screen mode throughout the app. Problem is whenever a dialog or popup appears status bar and navigation bar gets visible i.e. application goes out from full screen mode.

I've tried "SystemUiController" to hide both but I've to do it manually on every popup screen. Is there any way that application handles full screen popup and dialogs automatically?

1

There are 1 answers

0
Kauan On

I'm using this code to make my app fullscreen, per Android docs:

WindowCompat.getInsetsController(window, window.decorView)
            .hide(WindowInsetsCompat.Type.systemBars())

In the MainActivity, it can look like this:

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
        SampleAppTheme {
            Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
                WindowCompat.getInsetsController(window, window.decorView)
                    .hide(WindowInsetsCompat.Type.systemBars())

                SampleApp()
            }
        }
    }
}

}