17

My Toolbar Text, Back arrow and all is coming as black but I want it to be white
How can I achieve it?
My styles.xml looks like this:

<resources>

    <style name="AppTheme" parent="MyMaterialTheme.Base">

    </style>

    <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:textColor">@color/textColorPrimary</item>
        <item name="android:textStyle">normal</item>



    </style>


</resources>

Android Manifest Snippet:

 <application
        android:allowBackup="true"
        android:icon="@mipmap/hello"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
ojas
  • 2,150
  • 5
  • 22
  • 37
  • possible duplicate of [Android Theme.AppCompat.Light with Dark Toolbar (for light text)](http://stackoverflow.com/questions/27551230/android-theme-appcompat-light-with-dark-toolbar-for-light-text) – Rahul Tiwari Sep 26 '15 at 07:19

4 Answers4

27

Define a style for your toolbar:

<style name="AppToolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColorSecondary">@android:color/white</item>
</style>

Set it to your toolbar:

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|enterAlways"
        android:theme="@style/AppToolbar"
        android:minHeight="?attr/actionBarSize"/>
Devrim
  • 15,345
  • 4
  • 66
  • 74
14

If you make your Toolbar use the ThemeOverlay.AppCompat.Dark.ActionBar style, the text will be light. See this answer for more.

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1

refer this answer here

In order to change the color of the title in your Toolbar you simply have to add the attribute android:textColorPrimary to your Toolbar style.

Community
  • 1
  • 1
Rahul Tiwari
  • 6,851
  • 3
  • 49
  • 78
1

Try to use this these items in your themes.xml or styles.xml in values folder or values-v21 and other values folder.

<style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primaryColor</item>
        <item name="colorAccent">@color/primaryColor</item>
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:navigationBarColor">@android:color/black</item>

        <item name="actionMenuTextColor">@android:color/holo_blue_dark</item>
        <item name="android:actionMenuTextColor">@android:color/holo_blue_dark</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/black</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowBackground">@android:color/white</item>
        <item name="android:windowContentTransitions">true</item>
        </style>

Note:- remove these items from below API level 21.

        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/black</item>
        <item name="android:windowContentTransitions">true</item>
Shishram
  • 1,514
  • 11
  • 20