Reputation: 1378
I need to create material navigation drawer. I have already completed both header and menu with items. But I need to add this:
(in this example it is: " increase your limit") to the first item in drawer (this is just an design template).However, there is no parameter for aditional text...
My menu is in this typical format:
<item
android:id="@+id/blah"
android:title="@string/blah"
tools:icon="@drawable/blah" />
<group
android:id="@+id/drawer_group_primary"
android:checkableBehavior="single">
<item
android:id="@+id/blah"
android:title="@string/blah"
tools:icon="@drawable/blah" />
<item
android:id="@+id/blah"
android:title="@string/blah"
tools:icon="@drawable/blah" />
<item
android:id="@+id/blah"
android:title="@string/blah"
tools:icon="@drawable/blah" />
<item
android:id="@+id/blah"
android:title="@string/blah"
tools:icon="@drawable/blah" />
</group>
I can add additional layout to item, but it looks like this:example and i need to move that below title....
Upvotes: 2
Views: 1947
Reputation: 1762
To achieve your desired layout, you should make changes in your nav_header.xml
. You can customize nav_header as you want, because you can implement viewgroups and views beside menu..
Upvotes: 2
Reputation: 347
You should probaly use Navigation view instead of drawer. You could then use something like this :
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<include layout="@layout/include_list_viewpager"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>
and in the menu.xml you have to put this.
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_dashboard"
android:title="Home" />
....
<item
android:id="@+id/nav_discussion"
android:icon="@drawable/ic_forum"
android:title="Discussion" />
</group>
<item android:title="Sub items">
<menu>
<item
android:icon="@drawable/ic_dashboard"
android:title="Sub item 1" />
<item
android:icon="@drawable/ic_forum"
android:title="Sub item 2" />
</menu>
</item>
Upvotes: -1