Changing navigationView header text color

前端 未结 4 395
自闭症患者
自闭症患者 2021-01-03 08:33

How do you change the header text colors in navigation Drawer. I am using the latest support design library. Image is attached below.

相关标签:
4条回答
  • 2021-01-03 08:56

    I had a similar problem with group title color and I found the solution. Just put it into style.xml main theme.

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

    No need to modify your parent theme.

    0 讨论(0)
  • 2021-01-03 08:59

    Currently in the Material Components Library it is based on the android:textColorSecondary color.

    You can override this color only in the NavigationView using:

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

    with:

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

    Final result:

    0 讨论(0)
  • 2021-01-03 09:01

    Assuming you created it with a separate header xml file

    <?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>
    

    Just Change the background color of the relative layout

    Here is the link I used http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html?m=1

    0 讨论(0)
  • 2021-01-03 09:06

    Just changing the parent theme from Theme.Appcombat.Light.ActionBar to Theme.AppCombat solves it.

    0 讨论(0)
提交回复
热议问题