【问题标题】:Changing navigationView header text color更改 navigationView 标题文本颜色
【发布时间】:2015-07-07 19:40:51
【问题描述】:

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

【问题讨论】:

    标签: android navigationview android-navigationview


    【解决方案1】:

    我在组标题颜色方面遇到了类似的问题,我找到了解决方案。 把它放到style.xml主主题里就行了。

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

    无需修改您的父主题。

    【讨论】:

    • 我尝试了很多其他方法,但都没有奏效。但是您的解决方案对我有用。谢谢。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      假设您使用单独的头 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

      【讨论】:

      • 这是标题。我无法更改该菜单项标题。 “电视节目”和“电影”
      【解决方案4】:

      目前在材质组件库中,它基于 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>
      

      最终结果:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-20
        • 2017-07-11
        • 1970-01-01
        • 1970-01-01
        • 2014-12-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多