Screen always fit System Windows in Android Material Drawer

3.5k Views Asked by At

I am developing an Android app. In my app, I am using material drawer- https://github.com/mikepenz/MaterialDrawer to set up drawer on the left. I can set up the drawer easily. But it is having issue. It always fit to system windows like in the screenshot below.

enter image description here

This is how I set up drawer in activity.

private void setUpLeftDrawer()
    {
        DrawerBuilder builder = new DrawerBuilder()
                .withActivity(this)
                .withToolbar(toolbar);
        if(areas!=null && areas.size()>0)
        {

            for(Area area: areas)
            {
                PrimaryDrawerItem item = new PrimaryDrawerItem().withIdentifier(area.getId()).withName(area.getName());
                builder.addDrawerItems(item);
            }
        }

        builder.build();
    }

This is my main_activity xml.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="false"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- This LinearLayout represents the contents of the screen  -->


        <!-- The ActionBar displayed at the top -->
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <android.support.v7.widget.Toolbar
                android:fitsSystemWindows="false"
                android:id="@+id/toolbar"
                android:minHeight="?attr/actionBarSize"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:titleTextColor="@android:color/white"
                >
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.AppBarLayout>

        <!-- The main content view where fragments are loaded -->


</RelativeLayout>

So, I do not want it to fit System Windows. How can fix my code not to fit the system windows?

I tried setting this in the style XML as well

<item name="android:fitsSystemWindows">false</item>

It is not working as well.

1

There are 1 best solutions below

3
On

remove <item name="android:windowTranslucentStatus">true</item> from values-v21 styles

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowTranslucentStatus">true</item><!--this-->
    </style>