Oreo
Oreo

Reputation: 2594

How to change Toolbar Text Color in Pre-Lollipop versions

In Lollipop version, my Toolbar Text color is WHITE, but when i run my app on pre-lollipop devices then showing BLACK instead of WHITE color ...

styles.xml:-

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="colorPrimary">@color/ColorPrimary</item>
        <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>

    </style>

toolbar:

<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:background="@color/ColorPrimary"
    android:elevation="2dp"
    android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
    xmlns:android="http://schemas.android.com/apk/res/android" />

Upvotes: 1

Views: 794

Answers (3)

reVerse
reVerse

Reputation: 35254

You can customize the title textColor of the Toolbar via android:textColorPrimary.

Example

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    ...
    <!-- Used for the title -->
    <item name="android:textColorPrimary">#ffeb3b</item>
    <!-- Used for the menu and back-arrow - can be overriden by colorControlNormal -->
    <item name="android:textColorSecondary">#03a9f4</item>
</style>

Upvotes: 0

Suresh Kumar
Suresh Kumar

Reputation: 2034

Use the following

toolbarView.setTitleTextColor (toolbarTextColor);

Upvotes: 1

NarenderNishad
NarenderNishad

Reputation: 1068

You can change your Theme Theme.AppCompat.Light.NoActionBar to Theme.AppCompat.NoActionBar

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorPrimary">@color/primary</item>
        <item name="colorControlNormal">@color/primary_light</item>
        <item name="colorControlActivated">@color/primary</item>
        <item name="colorControlHighlight">@color/primary_dark</item>
    </style>

or add the item in your AppTheme

<item name="actionMenuTextColor">@android:color/white</item>

Upvotes: 1

Related Questions