My app has minSdkVersion 21
and targetSdkVersion 31
. I'd like the navigation drawer to be drawn over the status bar, but only when it is in the open state.
This is how the app looks like right now when the navigation drawer is closed, this is how I'd like it to be:
But the problem is when I open the drawer:
The status bar covers part of it and I'd like the drawer to be drawn over the status bar.
Currently, I have in main activity layout:
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@ id/drawer_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
...
In themes.xml
:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
How can I achieve the desired behavior? I've tried different approaches, but the one here is the closest to what I'd like to get. Except for the described minor detail.
CodePudding user response:
Upon researching the topic even more it turned out that the thing I'd like to achieve in the post doesn't make sense, because many phones have a camera area in the middle of the status bar and rendering the navigation drawer on top of the status bar will make parts of it be overlayed with the camera hole.