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