更改navigationView标题文本颜色

3
如何在导航抽屉中更改标题文本颜色。我正在使用最新的支持设计库。下面附有图片。
4个回答

12

我曾经遇到过类似的问题,是关于群组标题颜色的,后来我找到了解决方法。只需将其放入style.xml主题即可。

<item name="android:textColorSecondary">#FFFFFF</item>

无需修改您的父主题。


我尝试了很多其他方法,但它们都不起作用。但是你的解决方案对我有用。谢谢。 - Noundla Sandeep

2
只需将父主题从Theme.Appcombat.Light.ActionBar更改为Theme.AppCombat即可解决问题。

1
假设您使用单独的头部XML文件创建了它
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="178dp"
android:background="@drawable/background_poly"
android:orientation="vertical"
android:weightSum="1">



<LinearLayout
     android:layout_width="match_parent"
      android:layout_height="56dp"
     android:orientation="vertical"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:textColor="#ffffff"
        android:text="Akash Bangad"
        android:textSize="14sp"
        android:textStyle="bold"

        />

    <TextView
        android:id="@+id/email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="5dp"
        android:text="akash.bangad93@gmail.com"
        android:textSize="14sp"
        android:textStyle="normal"

        />
</LinearLayout>

    <de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:src="@drawable/aka"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="38dp"
    android:id="@+id/circleView"
   />
</RelativeLayout>

只需更改相对布局的背景颜色

这是我使用的链接 http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html?m=1


那是标题的部分。我无法更改该菜单项的标题。“电视节目”和“电影”。 - Vivek_Neel

1

目前Material Components Library基于android:textColorSecondary颜色。

您只能在NavigationView中使用以下方法覆盖此颜色:

<com.google.android.material.navigation.NavigationView
    android:theme="@style/ThemeOverlay.myCustomTitle"
    ..>

使用:

  <style name="ThemeOverlay.myCustomTitle" parent="">
    <item name="android:textColorSecondary">@color/....</item>
  </style>

最终结果:

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接