Skip to content Skip to sidebar Skip to footer

Android Drawerlayout (with Navigationview) Behind Status Bar

I have an app with a DrawerLayout that contains a NavigationView: activity_layout.xml:

Solution 1:

Just add <item name="android:windowTranslucentStatus">true</item> in values-21/styles.xml and remove this <item name="android:statusBarColor">@android:color/transparent</item>

add android:fitsSystemWindows="true" to your NavigationView in xml

Working example!

<stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBar"><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item><itemname="android:windowNoTitle">true</item><itemname="android:windowDrawsSystemBarBackgrounds">true</item><itemname="android:windowTranslucentStatus">true</item></style>

Result enter image description here

Edited (main layout)

<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true" <--Thisismandatorytools:context=".ui.activities.MainActivity"><FrameLayoutandroid:id="@+id/frame_container"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/white" /><android.support.design.widget.NavigationViewandroid:id="@+id/navigation"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="start"android:background="@color/colorPrimary"android:fitsSystemWindows="true" /><--This is mandatory 

</android.support.v4.widget.DrawerLayout>

Current Result enter image description here

Update: I lookup your style-v21 and found below

<?xml version="1.0" encoding="utf-8"?><resources><stylename="AppTheme.NoActionBar"parent="AppTheme"><itemname="android:windowDrawsSystemBarBackgrounds">true</item><itemname="android:windowTranslucentStatus">true</item></style></resources>

Please replace it with this

<stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBar"><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item><itemname="android:windowNoTitle">true</item><itemname="android:windowDrawsSystemBarBackgrounds">true</item><itemname="android:windowTranslucentStatus">true</item></style>

Post a Comment for "Android Drawerlayout (with Navigationview) Behind Status Bar"