I'm a complete beginner to Kotlin and Android development, I'm currently working on a todo list app as practice. I want to make the app take up the entire screen without any safe area at the top or bottom. With some effort I was able to hide the top system status bar, I've tried everything to also hide the bottom system navigation bar including this article but that solution doesn't help to solve my problem.
I'm running the app on a Google Pixel 8 Pro emulator with Android 14 (Upside Down Cake) and API level 34 and I'm on Gradle 8.5.2 and Kotlin 1.9.0 and my Android Studio version is 2024.1.1 patch 2 (Koala).
Any suggestions or advice on how to remove that bottom section is greatly appreciated. I suspect it's a handle for accessibility purposes so that the user can easily minimize the app, but it should be something that the developer can easily activate or deactivate.
Here's a gitlab link to my project
Here's relevant code snippets from the app, I've added all the suggestions from the comments but the issue still persists:
MainActivity.kt
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
WindowCompat.setDecorFitsSystemWindows(window, false)
val controller = WindowInsetsControllerCompat(window, window.decorView)
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
setContent {
ToDoListApp0Theme {
ToDoList()
}
}
}
}
AndroidManifest.xml
...
<activity
android:name=".MainActivity"
android:windowLayoutInDisplayCutoutMode="shortEdges"
android:fitsSystemWindows="false"
...
themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ToDoListApp0" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>style>
</resources>
In order to hide the handle you shall use the immersive mode: WindowInsetsControllerCompat.hide()
In addition use WindowInsetsControllerCompat.setSystemBarsBehavior()
to specify how hidden system bars behave when the user interacts with them, in fact the user shall be able to reveal hidden system bars in order to get back control of the device.