Reputation: 25
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.sstatic.net/Zw5Tk.png
Upvotes: 1
Views: 2189
Reputation: 3437
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
Upvotes: 0
Reputation: 1572
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>
Upvotes: 2