更改导航视图项目颜色动态地机器人 [英] Change Navigation View Item Color Dynamicly Android

查看:213
本文介绍了更改导航视图项目颜色动态地机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个导航抽屉里的每个项目都有不同的颜色选择(图标色彩和文字颜色)为谷歌Play商店有:

I'd like to build a navigation drawer where each item has a different selection color (the icon tint and text color) as the google play store has:

我不知道他们是如何解决这个问题,我认为他们使用不同的活动,不同的抽屉。我想用碎片,我想改变图标的​​色彩和文字颜色。任何想法如何,我可以做到这一点?我使用的是谷歌的设计支持库,并在有导航视图抽屉布局。

I'm not sure how they've solved this, I think they use different activities with different drawers. I want to use fragments and I want to change the icon tint and text color. Any ideas how I can do this? I'm using google's design support library and a drawer layout with a navigation view in there.

推荐答案

使用应用:itemIconTint NavigationView 用于图标,并使用应用:itemTextColor 的textColors

use app:itemIconTint in your NavigationView for icons and use app:itemTextColor for textColors

示例:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- This is used when the Navigation Item is checked -->
    <item android:color="#009688" android:state_checked="true" />
    <!-- This is the default text color -->
    <item android:color="#E91E63" />
</selector>

这篇关于更改导航视图项目颜色动态地机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆