简体   繁体   English

更改导航抽屉中菜单标题标题项的文本颜色

[英]Changing text color of menu heading title item in navigation drawer

I'm trying to implement dark mode in my application.我正在尝试在我的应用程序中实现暗模式。 I've implemented on menu item.我已经在菜单项上实现了。 It is changing the color but what I want is to change the color of heading as well because when dark mode is implemented the heading menu is hidden as the color is light grey.它正在改变颜色,但我想要改变标题的颜色,因为当实施暗模式时,标题菜单被隐藏,因为颜色是浅灰色。

Navigation Menu:导航菜单:

   <android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="?attr/bgColor"
    app:itemTextColor="?attr/textColor"
    app:headerLayout="@layout/nav_header_home"
    app:menu="@menu/nav_items" />

轻主题

黑暗主题

Add <item name="android:textColorSecondary">@color/white</item> inside your AppTheme and AppTheme.NoActionBar styles.xml file like this:在您的AppThemeAppTheme.NoActionBar styles.xml 文件中添加<item name="android:textColorSecondary">@color/white</item> ,如下所示:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:textColorSecondary">@color/white</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

        <item name="android:textColorSecondary">@color/white</item>
    </style>
...
</resources>

where the color value <color name="white">#FFFFFF</color> is placed in colors.xml .其中颜色值<color name="white">#FFFFFF</color>放置在colors.xml中。

The result looks exactly like you wanted:结果看起来与您想要的完全一样:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM