如何使用android NavigationView中的菜单项创建类似网格的视图

如何使用android NavigationView中的菜单项创建类似网格的视图,android,android-layout,Android,Android Layout,我有一个带导航抽屉的android应用程序。它有一系列类似Gmail应用程序的菜单,如下所示 <?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" xml

我有一个带导航抽屉的android应用程序。它有一系列类似Gmail应用程序的菜单,如下所示

<?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"
tools:openDrawer="left">

<include
    layout="@layout/app_bar_dashboard"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

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

我希望菜单列表是一个网格状的视图。如何实现这一点?

您可以使用自定义布局代替NavigationView。使用网格设计创建布局文件,并将其包含在此文件中,而不是NavigationView

 <LinearLayout
        android:id="@+id/left_drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        android:orientation="vertical">

        <include layout="@layout/layout_grid_left" />
    </LinearLayout>
并使用左视图创建布局网格左视图

您可以在此处查看: