Android Change Navigation View Menu Background - android

In my app i want to change the navigation view menu background, but i dont know how to do this. All posts i have watched explains how to change each menu item background, but all i need is to change the entire background of the menu.
This is what i want to change, the entire white background:
activity_main_drawer.xml:
<?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_camara" android:icon="#android:drawable/ic_menu_camera"
android:title="Import" />
<item android:id="#+id/nav_gallery" android:icon="#android:drawable/ic_menu_gallery"
android:title="Gallery" />
<item android:id="#+id/nav_slideshow" android:icon="#android:drawable/ic_menu_slideshow"
android:title="Slideshow" />
<item android:id="#+id/nav_manage" android:icon="#android:drawable/ic_menu_manage"
android:title="Tools" />
</group>
<item android:title="Communicate">
<menu>
<item android:id="#+id/nav_share" android:icon="#android:drawable/ic_menu_share"
android:title="Share" />
<item android:id="#+id/nav_send" android:icon="#android:drawable/ic_menu_send"
android:title="Send" />
</menu>
</item>
</menu>
Is there anyway to change the white background from the activity_main_drawer layout?
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_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" tools:openDrawer="start">
<include layout="#layout/app_bar_main" 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" android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main" app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Thanks in advance.

You can set background to your NavigationView to change its color like below (set to app_white ) & for header set any color as a background of drawer_header_layout.
<android.support.design.widget.NavigationView
android:id="#+id/adcl_navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/app_white"
app:headerLayout="#layout/drawer_header_layout"
app:itemIconTint="#color/app_secondary_text"
app:itemTextColor="#color/app_secondary_text"
app:menu="#menu/menu_drawer"
app:theme="#style/ThemeOverlay.AppCompat.Light" />

just add android:background="#color/yourColor" to the <android.support.design.widget.NavigationView.

Related

Why the texts inside the navigation drawer are not the same?

Can I know why the texts inside the navigation drawer are not the same?
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainActivity"
tools:openDrawer="start">
...
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/menu_navigation_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
----------
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Other">
<menu>
<item
android:icon="#drawable/ic_star"
android:title="Rate the app" />
<item
android:icon="#drawable/ic_share"
android:title="Share the app" />
<item
android:icon="#drawable/ic_shield"
android:title="Privacy policy" />
<item
android:icon="#drawable/ic_document"
android:title="Terms of services" />
</menu>
</item>
</menu>
Notice some items have bold texts and some items have regular texts.
Why is that happening?
I'm using Material Design 3.
The solution
<style name="styleName" parent="TextAppearance.Material3.LabelLarge">
<item name="fontFamily">#font/font_regular</item>
</style>
Then add this inside NavigationView
app:itemTextAppearance="#style/styleName"

Set Margin to Navigation Drawer's Default Divider

I tried to set margin to default navigation drawer's "divider" attribute. I found many approach in Stackoverflow form but none of the answers are adequate.
I could create a custom navigation drawer list without using /menu/activity_main_drawer.xml. That looks like what I want. But I have concerns about the performance of the application.
I want to add margin to default divider. Is there a way to customize default navigation drawer divider?
That is my customized divider. Everything is perfect.
That is the default navigation drawer's divider which I could not give any margin.
style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:listDivider">#color/colorAccent</item>
...
</style>
divider_layout.xml
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="60dp"
android:insetRight="8dp" >
<shape>
<solid android:color="#c0c0c0" />
</shape>
</inset>
activity_main_drawer.xml
<?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/rakipicon"
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>
activity_main.xml
<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"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
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"
android:divider="#drawable/divider_layout"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
I know it's been a while, but for anyone that might stumble upon this, I had the same issue and resolved it like this.
Where you define the navigation view, you can just set padding horizontal, which will set a padding for the entire navigation view. This will apply to the dividers as well.
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingHorizontal="24dp">
You can create a drawable named menu_divider.xml in your resources folder:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="#c0c0c0"
android:left="16dp"
android:right="16dp" />
and set your navigation view to use it:
<style name="ThemeOverlay.App.NavigationView" parent="">
<item name="android:listDivider">#drawable/menu_divider</item>
</style>
Just add this in the drawer layout:
app:dividerInsetEnd="25dp"
app:dividerInsetStart="57dp"
Like below:
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:dividerInsetEnd="25dp"
app:dividerInsetStart="57dp"
app:elevation="32dp"
app:headerLayout="#layout/nav_header_main"
app:itemIconTint="#color/gray"
app:itemTextColor="#color/gray"
app:menu="#menu/activity_main_drawer">

Different dividers between items and sub items in NavigationView

I trying to have dividers between items in my NavigationView, I tried with DividerItemDecoration but it didn't work exactly as I wanted.
MainActivity layout:
<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_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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:customTypeface="#string/font_lato_light"
app:itemTextColor="#color/drawer_text_color_selector"
app:itemTextAppearance="#style/TextViewBody"
app:itemIconTint="#color/mainBlue"
app:itemBackground="#drawable/menu_item_bg"
app:menu="#menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>
and this is my menu
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:title="#string/historico" >
<menu>
<item
android:id="#+id/menu_historico"
android:icon="#drawable/user"
android:title="#string/historico" />
</menu>
</item>
<item android:title="#string/pagamento">
<menu>
<item
android:id="#+id/menu_pagamento"
android:icon="#drawable/user"
android:title="#string/pagamento" />
</menu>
</item>
<item android:title="#string/definicoes">
<menu>
<item
android:id="#+id/menu_terms"
android:icon="#drawable/user"
android:title="#string/terms" />
<item
android:id="#+id/menu_lang"
android:icon="#drawable/user"
android:title="#string/alterar_idioma" />
<item
android:id="#+id/menu_pass"
android:icon="#drawable/user"
android:title="#string/gestao_pass" />
<item
android:id="#+id/menu_ped"
android:icon="#drawable/user"
android:title="#string/gestao_ped" />
<item
android:id="#+id/menu_info"
android:icon="#drawable/user"
android:title="#string/informacao_pessoal" />
<item
android:id="#+id/menu_faqs"
android:icon="#drawable/user"
android:title="#string/faqs" />
<item
android:id="#+id/menu_suggest"
android:icon="#drawable/user"
android:title="#string/Sugestoes" />
<item
android:id="#+id/menu_end_session"
android:icon="#drawable/user"
android:title="#string/terminar_sessao" />
</menu>
</item>
This is the result.
and what im trying to get is this
Is there anyway to add diferent dividers between items and sub-items?

How can I change separator color in NavigationView?

I'm trying to use NavigationView to implement NavigationDrawer. I have added the separator by setting group id in menu. However I can't see the separator. I guess it is because the separator color is same as the background. So I want to change the separator color. But I find no way to change it. Can anyone help me?
In screenshot, it seems have a room for separator between History and Settings, but you can't see it.
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:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context=".ui.MapActivity">
<LinearLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/toolbar_actionbar" />
<!--main content-->
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/navdrawer_background"
app:insetForeground="#4000"
app:itemTextColor="#color/navdrawer_item_text_color"
app:itemIconTint="#color/navdrawer_item_icon_tint"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="#+id/group_feature"
android:checkableBehavior="single">
<item android:id="#+id/navdrawer_item_map"
android:checked="true"
android:icon="#drawable/ic_drawer_map"
android:title="#string/navdrawer_item_map"/>
<item android:id="#+id/navdrawer_item_favourite"
android:icon="#drawable/ic_drawer_fav"
android:title="#string/navdrawer_item_fav"/>
<item android:id="#+id/navdrawer_item_history"
android:icon="#drawable/ic_drawer_history"
android:title="#string/navdrawer_item_history"/>
</group>
<group android:id="#+id/group_settings"
android:checkableBehavior="single">
<item android:id="#+id/navdrawer_item_settings"
android:icon="#drawable/ic_drawer_settings"
android:title="#string/navdrawer_item_settings"/>
<item android:id="#+id/navdrawer_item_help"
android:icon="#drawable/ic_drawer_help"
android:title="#string/navdrawer_item_help"/>
<item android:id="#+id/navdrawer_item_about"
android:icon="#drawable/ic_drawer_about"
android:title="#string/navdrawer_item_about"/>
</group>
</menu>
just apply following line on style.xml
<item name="android:listDivider">your_color</item>
The below is just information for your knowledge ...
If you have seen design support library .. they are using following layout for NavigationView seprator..
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
</FrameLayout>
here, you can see android:background="?android:attr/listDivider" ..
So enjoy ...
and here is my output that i change color to holo_blue
Here is best and easy way while using menu as view
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:theme="#style/ThemeToolbar.NavigationView"
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:headerLayout="#layout/activity_home_nav_header"
app:menu="#menu/activity_home_drawer" />
ThemeToolbar.NavigatinoView
<style name="ThemeToolbar.NavigationView" >
<item name="android:listDivider">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
</style>
Create a style in your styles.xml. Enter your preferred color in the android:listDivider
<style name="NavigationView" parent="Base.Theme.AppCompat">
<item name="android:listDivider">#color/text_lightgray</item>
</style>
Reference the style as the theme of your navigation view:
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
android:theme="#style/NavigationView"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_view"
app:itemTextColor="#color/text_white"/>
Lastly, make sure that the groups inside your menu have unique ids. If your groups do not have the id attribute, this won't work!
<group android:checkableBehavior="single"
android:id="#+id/group1">
<item
android:id="#+id/item1"
android:title="#string/item1" />
</group>
<group android:checkableBehavior="single"
android:id="#+id/group2">
<item
android:id="#+id/item2"
android:title="#string/item2" />
</group>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/menu_text_color</item>
<item name="android:textColorSecondary">#color/menu_text_color</item>
</style>
textColorPrimary changes the color of the header.
Perfect answer:
<android.support.design.widget.NavigationView
android:id="#+id/activity_principal_nav_view"
android:layout_width="#dimen/size_230"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/black"
android:fitsSystemWindows="true"
app:insetForeground="#color/white"
app:menu="#menu/settings_menu"
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:headerLayout="#layout/settings_menu_header"
android:theme="#style/NavigationDrawerStyle"/>
Divider Color Is Changed
STEP 1:
Create list_divider.xml file in your drawable folder.
copy and paste the following lines into your list_divider.xml.
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="#dimen/_16sdp"
android:insetRight="#dimen/_16sdp">
<shape>
<solid android:color="#FFFFFF" />
<size android:height="2dp" />
</shape>
</inset>
STEP 2:
Add this line to your Main Theme ( Theme Mentioned in your AndroidManifest.xml file)
<item name="android:listDivider">#drawable/list_divider</item>
For Example
<style
name="MyMaterialTheme.Base"
parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:listDivider">#drawable/list_divider</item>
<item name="android:listDivider">#drawable/list_divider</item>
STEP 3:
No Change required in NavigationView for divider Color
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigationView"
android:layout_width="#dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/colorPrimary"
app:headerLayout="#layout/header_navigation_drawer"
app:itemIconTint="?attr/nav_drawer_icon_color"
app:itemTextColor="?attr/nav_text_color"
app:menu="#menu/navigation_drawer_list_menu"
tools:ignore="MissingConstraints" />

See navigation drawer preview

I'm designing a native navigation drawer in Android Studio.
I can't see the drawer in my preview because it is sitting left of the activity, out of range of the preview.
For now I'm using a testlayout.xml file to see my changes, but a lot of times I forget to copy paste them into the right activity.
Is there a way to preview the drawer layout?
If you want to be able to preview the drawer layout / navigation bar
If you are following the tutorial at https://developer.android.com/training/implementing-navigation/nav-drawer.html
You can put your listview for the nav drawer in a different xml file in the /layout folder, then include it in the drawer layout xml. Means you can edit it in the drawer_layout file and be able to see it properly
layout/drawer_layout
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#color/nav_drawer_background_color"/>
Then in the navbar
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<!-- The navigation drawer -->
<include
android:id="#+id/listView"
layout="#layout/drawer_layout"/>
</android.support.v4.widget.DrawerLayout>
To see NavigationView preview add tools namespace to your drawer layout:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
then add attribute tools:openDrawer equal to gravity of layout_gravity value of your Navigation view, for example
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:openDrawer="left">
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
app:headerLayout="#layout/navigation_header_main"
app:itemTextAppearance="#style/NavigationItemStyleLight"
app:menu="#menu/navigation_main_menu"/>
</android.support.v4.widget.DrawerLayout>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<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>
Just Add
tools:showIn="navigation_view"
You can use NavigationView to get its preview on AndroidStudio, Its much better and easier to implement then the old NavigationDrawer.
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_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/prof_app_bar"
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"
android:fitsSystemWindows="true"
app:itemTextColor="#color/text_head_color"
app:itemIconTint="#null"
app:headerLayout="#layout/nav_header_main2"
app:menu="#menu/professional_menu" />
</android.support.v4.widget.DrawerLayout>
Define the menu in navigationmenu.xml place it in menu resource folder:-
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single"
android:id="#+id/top_menu">
<item
android:id="#+id/pnav_setting"
android:icon="#drawable/accountsettings"
android:title="#string/paccount_settingss" />
<item
android:id="#+id/pnav_expertise"
android:icon="#drawable/professional"
android:title="#string/pexpertise" />
<item
android:id="#+id/pnav_comu"
android:icon="#drawable/communication"
android:title="#string/pcomunication" />
<item
android:id="#+id/pnav_change_pass"
android:icon="#drawable/changepasswd"
android:title="#string/pchange_pass" />
<item
android:id="#+id/pnav_change_lang"
android:icon="#drawable/changelang"
android:title="#string/pchange_lang"
android:visible="true"/>
</group>
<group android:checkableBehavior="single"
android:id="#+id/middle_menu">
<item
android:id="#+id/pnav_about_us"
android:icon="#drawable/aboutus"
android:title="#string/about_us" />
<item
android:id="#+id/pnav_feedback"
android:icon="#drawable/feedback"
android:title="#string/feedback"
android:visible="false"/>
<item
android:id="#+id/nav_privacy_policy"
android:icon="#drawable/privacy"
android:title="#string/privacy_policy" />
<item
android:id="#+id/pnav_faq"
android:icon="#drawable/faq"
android:visible="false"
android:title="#string/faq" />
<item
android:id="#+id/pnav_contact_us"
android:icon="#drawable/contactus"
android:title="#string/contact_us" />
</group>
<group android:checkableBehavior="single"
android:id="#+id/bottom_menu">
<item
android:id="#+id/pnav_sign_out"
android:icon="#drawable/signout"
android:title="#string/sign_out" />
</group>
</menu>
And, for getting click events use this:-
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(yourItemclickListener);

Categories

Resources