Ludovico Parsi
Ludovico Parsi

Reputation: 61

Navigation Drawer below Status Bar

I'm tring to make a Navigation Drawer using Design Support Library. In my activity_main i wrote this code.

<?xml version="1.0" encoding="utf-8"?>

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        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">

    <LinearLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"/>

    <FrameLayout 
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>   

    </LinearLayout>

   <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/header_layout"
        app:menu="@menu/menu_drawer"/>  

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

When i run my application it works and show the Navigation Drawer but it's below the Status Bar and not above. How can i move it to stay above the StatusBar?

Upvotes: 6

Views: 2948

Answers (3)

Ritesh
Ritesh

Reputation: 896

Simply adding android:fitsSystemWindows="false" to DrawerLayout will solve the problem.

Upvotes: 14

shubomb
shubomb

Reputation: 832

use this on navigation view xml :

app:insetForeground="#ffffff"

Upvotes: 0

Androider
Androider

Reputation: 3873

Make your activity as full screen to overcome status bar as below or any other method as available on WWW: but it's not good to have drawer over status bar.

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}

Upvotes: 0

Related Questions