0

enter image description here

This is sample for navigation drawer when I create navigation drawer.

and this is code.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_camera"
            android:icon="@drawable/ic_menu_camera"
            android:title="Import" />
        <item
            android:id="@+id/nav_gallery"
            android:icon="@drawable/ic_menu_gallery"
            android:title="Gallery" />
        <item
            android:id="@+id/nav_slideshow"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="Slideshow" />
        <item
            android:id="@+id/nav_manage"
            android:icon="@drawable/ic_menu_manage"
            android:title="Tools" />
    </group>

    <item android:title="Communicate">
        <menu>
            <item
                android:id="@+id/nav_share"
                android:icon="@drawable/ic_menu_share"
                android:title="Share" />
            <item
                android:id="@+id/nav_send"
                android:icon="@drawable/ic_menu_send"
                android:title="Send" />
        </menu>
    </item>

</menu>

I want put left margin Gallery and Slideshow to show like subgroup in navigation view.

How I can do it?

I group of that but it is same, not occur

I want see them like subgroup.

If you know about this, please help me

Polaris Nation
  • 1,085
  • 2
  • 18
  • 49

1 Answers1

0

Try creating a custom navigation drawer lay out rather than using a menu.

Like this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:padding="10dp">

  <ImageView
      android:id="@+id/drawer_item_icon"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:paddingRight="10dp"/>

  <TextView
      android:id="@+id/drawer_item_name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"
      android:layout_toRightOf="@+id/drawer_item_icon"
      android:paddingRight="10dp"
      android:textSize="21sp"
      android:textAppearance="?android:attr/textAppearanceListItemSmall"
      android:textColor="@android:color/white"/>

</RelativeLayout>

you can define your custom layout attributes in here.

for more details please follow this tutorial

android custom navigation drawer

MaxExplode
  • 1,977
  • 2
  • 17
  • 27