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

问题描述 投票:0回答:1

我正在尝试在应用程序中实现暗模式。我已经实现了菜单项。它正在改变颜色,但是我想要的是也改变标题的颜色,因为当实施暗模式时,标题菜单被隐藏,因为颜色是浅灰色。

导航菜单:

   <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" />

Light Theme

Dark Theme

android
1个回答
0
投票

像这样在<item name="android:textColorSecondary">@color/colorPrimary</item>AppTheme styles.xml文件中添加AppTheme.NoActionBar

<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/colorPrimary</item>
</style>
© www.soinside.com 2019 - 2024. All rights reserved.