在NavigationView中的彩色的图标 [英] Colored Icons In NavigationView
本文介绍了在NavigationView中的彩色的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天,有没有办法在导航抽屉上显示彩色图标?
不对它们进行着色或将它们设置为黑色,并且在导航抽屉中单击时,每个都会有相应的颜色(突出显示/背景)。
就像谷歌商店应用程序抽屉。
Just like Google Store App drawer.
推荐答案
是的,您可以使用菜单组项添加彩色图标:
Yes you can add colored icon using menu group items:
<item
android:id="@+id/drawer_artist"
android:icon="@drawable/artist"
android:title="Artists"/>
用于突出显示所选项目使用以下代码进行默认选择:
And for highlighting the selcted item Use the code below for default selection:
navigationView.getMenu().getItem(0).setChecked(true);
您可以通过调用
onNavigationItemSelected(navigationView.getMenu().getItem(0));
修改
如果您使用的是导航视图,则可以编辑更改图标颜色的选项,如下所示:
If you are using navigationview you can edit option for changing the colortint of icons as follows:
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@drawable/bg_all"
app:itemIconTint="@android:color/white"
app:itemTextColor="@android:color/white"
app:theme="@style/list_item_appearance"
app:menu="@menu/drawer_menu" >
修改
如果设置 navigationView.setItemIconTintList(null);
,您将获得彩色图标。
If you set navigationView.setItemIconTintList(null);
you will get colored icons.
这篇关于在NavigationView中的彩色的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文