0

I have added navigation drawer in my app, and it opens like following

enter image description here

But i want to open the drawer to full width like following.

enter image description here

I checked some answers on SO, and set margin to -64dp but that didn't help, is it possible to set width of navigation drawer to full screen.

dev90
  • 7,187
  • 15
  • 80
  • 153
  • Do you still need to be able to drag it open and closed? If not, the best thing to do might be to just get rid of the `DrawerLayout`, and animate a full-width `View`/`Fragment` in and out on that side. – Mike M. Nov 23 '19 at 09:53

5 Answers5

2

just add this code in your Navigation View that's it

android:layout_gravity="start"
android:fitsSystemWindows="true"
android:layout_marginEnd="-65dp"
android:layout_marginRight="-65dp"
Farhan Fahim
  • 137
  • 2
  • 7
1

You can try this

<android.support.design.widget.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        android:layout_marginEnd="-65dp"
        android:layout_marginRight="-65dp"
        app:itemTextAppearance="@style/TextAppearance.AppCompat.Small"
        app:headerLayout="@layout/drawer_header">
1

try this!!! work perfectly

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    android:layout_marginEnd="-65dp"
    android:layout_marginRight="-65dp"
    app:itemTextColor="@color/lightgray"
    app:itemIconTint="@color/colorAccent"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer" />
UD..
  • 80
  • 4
  • 10
0

Set full width navigation drawer in android

Just call this method and pass your drawerlayout as parameter.

public static void fixDrawerMargin(DrawerLayout drawerLayout) {
        try {
            Field f = DrawerLayout.class.getDeclaredField("mMinDrawerMargin");
            f.setAccessible(true);
            f.set(drawerLayout, 0);

            drawerLayout.requestLayout();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Bhavik Nathani
  • 470
  • 5
  • 13
0

try this code:

<android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_marginEnd="-65dp"
        android:layout_marginRight="-65dp"
        android:fitsSystemWindows="true">
      />
Marium Jawed
  • 391
  • 4
  • 9