在NavigationDrawer中更改特定图标的颜色 [英] Change specific icon's color in NavigationDrawer
本文介绍了在NavigationDrawer中更改特定图标的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Android的默认抽屉菜单"中更改图标的颜色时遇到问题,有很多主题,但是它们仅说明了更改整个菜单的颜色而不是特定图标的颜色:
I have a problem with changing the icon's color in default Drawer Menu in Android, there are lots of topics but they only explain changing the tint color of whole menu not a specific icon:
例如,我想将收藏夹"图标的颜色更改为黄色
For example I want to change the color of Favorites icon to yellow
推荐答案
您可以在此处从activity_drawer_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"
<!-- Change your drawable here -->
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>
</menu>
要消除色彩效果,请使用此
To remove tint color effect use this
mNavigationView.setItemIconTintList(null);
这篇关于在NavigationDrawer中更改特定图标的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文