Android: Toolbar text is coming as black instead of white

ojas picture ojas · Sep 26, 2015 · Viewed 13.6k times · Source

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

Answer

Devrim picture Devrim · Sep 26, 2015

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"/>