I want to add style the Menu Items inside Navigation Drawer but I am unable to do so. I have looked up for some answers but couldn't done it.
Can anyone help, I would be grateful.
I am using the following theme Theme.AppCompat.Light.DarkActionBar
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group1" android:checkableBehavior="single">
<item android:title="Book Now!">
<menu>
<item android:title="item 1"
android:id="@+id/item1"
android:icon="@drawable/ic_menu_gallery"/>
<item android:title="item 2"
android:id="@+id/item2"
android:icon="@drawable/ic_menu_gallery"/>
<item android:title="item 3"
android:id="@+id/item3"
android:icon="@drawable/ic_menu_gallery"/>
<item android:title="item 4"
android:id="@+id/item4"
android:icon="@drawable/ic_menu_gallery"/>
<item android:title="item 5"
android:id="@+id/item5"
android:icon="@drawable/ic_menu_gallery"/>
</menu>
</item>
</group>
</menu>
You have to use OnNavigationItemSelectedListener(MenuItem item) method.
The navigation drawer is a UI panel that shows your app's main navigation menu. The drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen.
Step 1: Create Selector for change font color
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/red" android:state_checked="true" />
<item android:color="#bdbdbd" />
</selector>
Step 2: Apply selector to navigation view by app:itemTextColor property
<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:background="@color/appColor"
android:fitsSystemWindows="true"
app:itemTextAppearance="@style/NavigationDrawerStyle"
app:headerLayout="@layout/nav_header_home"
app:itemBackground="@color/appColor"
app:itemTextColor="@color/drawable_selector_drawer_item"
app:menu="@menu/activity_home_drawer" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With