java - 抽屉导航项目标题颜色

标签 java android xml

我一直在寻找解决这个问题的方法,但我似乎找不到答案。我在这个抽屉导航中有多个项目,每个项目都有一个其他项目的菜单。父项目有一个与之关联的标题,我想更改文本颜色,但我似乎无法在任何地方找到答案。非常感谢您的帮助,这里有一张图片可以更准确地理解我的问题。

Navigation Drawer: Android Studio

提前感谢您的帮助!

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    android:background="@color/colorPrimaryDark"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer"
    app:itemTextColor="@color/white"
    app:itemIconTint="@color/white" />

</android.support.v4.widget.DrawerLayout>

最佳答案

如果您正在使用 Material Design 库中引入的 NavigationView,请添加以下属性来更改抽屉项目的颜色

<android.support.design.widget.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:itemBackground="@drawable/my_ripple"    //sets background of the item
    app:itemIconTint="@color/item_icon_color"      //sets color of the drawer item icon
    app:itemTextColor="@color/item_color"     //sets color of the drawer item
    ....
 />

关于java - 抽屉导航项目标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36076119/

相关文章:

android - 视频播放器开始播放时如何暂停音频播放器?

android - 如何获取当前正在运行的所有任务

android - 无法从代码中找到已声明的 XML 样式

xml - 是否可以将JSON转换为XML并将XML转换为JSON而无需序列化/反序列化为特定对象

java - 无法使用 jdbc 数据源配置 Spring Security

java - 如何使用@JsonTypeInfo 和@JsonSubTypes 来实例化具有不同配置的类?

java - 字符串在 for 循环中被覆盖

java - 使用maven只部署部分依赖

java - 如何将值传递给模型类

即使我使用了相同的路径来保存它,Android Intent 也会打开空白 PDF