1

How can I make my navigation drawer as wide as what is suggested (like in the Gmail app)?

enter image description here

In my app it only extends to just over half of the screen.

activity_main.xml

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context="com.example.apple.bookshelf.MainActivity">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  />

        </android.support.design.widget.AppBarLayout>

        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/authors_list_view"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <include layout="@layout/content_main" />

    </android.support.design.widget.CoordinatorLayout>

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

</android.support.v4.widget.DrawerLayout>
Sebastian
  • 3,548
  • 18
  • 60
  • 95
  • what does it look like in your app? – tyczj Nov 10 '17 at 18:42
  • The same as above, but not as wide. It's the width of just over half the screen. – Sebastian Nov 10 '17 at 18:46
  • as per the official specs this is what the size should be `Maximum width: The maximum width of the nav drawer is 280dp on mobile and 320dp on tablet. This is calculated by multiplying the standard increment by five (the standard increment is 56dp on mobile and 64dp on tablet).` so set that width – tyczj Nov 10 '17 at 18:47
  • I changed `android:layout_width="280dp"` on NavigationView but it didn't do anything – Sebastian Nov 10 '17 at 18:50
  • IIRC you change the drawer layout width – tyczj Nov 10 '17 at 19:38
  • @Sebastian hope you found a solution, please let us know – trocchietto Nov 15 '17 at 21:23

1 Answers1

0

Possibly you could try to customize the Navigation drawer. The official documentation says

If none of the prebuilt widgets or layouts meets your needs, you can create your own View subclass.

you could think to create your own Navigation Drawer, here are offered several solutions, also the possibility to use libraries, you can see the source code, but also trying in the classical way, extending the class you need and override the methods you want to change

trocchietto
  • 2,607
  • 2
  • 23
  • 36