How to enable fullscreen in Jetpack Compose apps

120 views Asked by At

I'm learning Jetpack Compose with Kotlin, and trying to make an app with the option to enable fullscreen mode in Android, only showing the status bar after swiping it down.

I've searched for examples online, but none of them worked for me yet.

Some can hide the status bar, but still left a black bar; some can display full screen UI, but the status bar contents are still there.

The default project gives me

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            ...
        }
    }
}

what I've got is immersive

Then I added codes after enableEdgeToEdge()

val insetsController = WindowCompat.getInsetsController(window, window.decorView)
insetsController.apply {
    hide(WindowInsetsCompat.Type.statusBars())
    hide(WindowInsetsCompat.Type.navigationBars())
    systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}

What I've got is the black status bar area

0

There are 0 answers