Navigation View item menu background color

 drawable/nav_item_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/blue" android:state_pressed="true"/>
    <item android:drawable="@color/blue" android:state_focused="true"/>
    <item android:drawable="@color/blue" android:state_activated="true"/>
    <item android:drawable="@color/blue" android:state_checked="true"/>
    <item android:drawable="@color/none"/>
</selector>

 drawable/nav_item_text.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/white" android:state_checked="true"/>
    <item android:color="@color/white"/>
</selector>

 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/menu_live_list"
            android:icon="@drawable/menu_icon_livelist"
            android:title="@string/txt_livelist"/>
        <item
            android:id="@+id/menu_mylive"
            android:icon="@drawable/menu_icon_mylive"
            android:title="@string/txt_mylive"/>
    </group>
</menu>

设置Menu 下面Item 图标及文本颜色

<android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:layout_marginBottom="@dimen/toolbar_padding_bottom"
        android:background="@drawable/login_bac"
        android:fitsSystemWindows="false"
        app:itemBackground="@drawable/selector_nav_item_bg"
        app:itemTextColor="@color/selector_nav_item_text"
        app:itemIconTint="@color/selector_nav_item_text"/>

相关推荐