How to style Menu Items in Navigation Drawer in Android?

后端 未结 1 1654
天涯浪人
天涯浪人 2020-12-31 08:20

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 he

相关标签:
1条回答
  • 2020-12-31 09:10

    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" />
    
    0 讨论(0)
提交回复
热议问题