Home > Software engineering >  How can I remove the status bar in android studio?
How can I remove the status bar in android studio?

Time:09-18

So basically I want to remove the status bar of my app and I've found no solution. I don't want to make my app fullscreen I just want that part to be transparent and have more space for my app. I tried changing the color of the status bar to transparent but nothing works. Any help would be appreciated! I will attach a photo with the part that I want to remove to be more specific.

https://i.stack.imgur.com/Zw5Tk.png

CodePudding user response:

if you don't want to make your app full screen, you should make the status bar transparent. So add this line to your theme.xml file:

 <item name="android:windowTranslucentStatus">true</item>

Therefore, your theme.xml should be something like this:

<resources>
    <style name="Theme.MyApp" parent="android:Theme.Material.Light.NoActionBar">
      <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

CodePudding user response:

You can use WindowInsetsControllerCompat API to acheive this

You can try this function . Add this in onCreate() of activity.

private fun hideStatusBar() {
    WindowCompat.getInsetsController(window,window.decorView).apply {
        systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        hide(WindowInsetsCompat.Type.statusBars())
    }
}

Click here to read more

  • Related