Reputation: 7519
I have added navigation drawer
in my app, and it opens like following
But i want to open the drawer to full width like following.
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.
Upvotes: 0
Views: 728
Reputation: 419
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">
/>
Upvotes: 0
Reputation: 499
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();
}
}
Upvotes: 0
Reputation: 80
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" />
Upvotes: 1
Reputation: 137
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"
Upvotes: 2
Reputation: 395
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">
Upvotes: 1