Anbarasu Chinna
Anbarasu Chinna

Reputation: 1005

How can i create Grid like view using Menu Item in android NavigationView

I have an android application with navigation drawer. It has list of menu like Gmail application as follows

<?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" />

enter image description here

I want that menu list to be a grid like view. how can i achieve that?

Upvotes: 0

Views: 252

Answers (1)

Muhib Pirani
Muhib Pirani

Reputation: 775

Instead of NavigationView you can use your custom layout. create a layout file with Grid design and include it here in this file instead of 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>

and create layout_grid_left with your left View

Upvotes: 1

Related Questions