-2

I use a toolbar and when scrolling the image it shows with text, I try in java also toolbar.setTitleTextColor(Color.RED); But it does not work the text color always white

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:titleTextColor="@color/buttontext"
            app:popupTheme="@style/appBarTheme" />
Muthukrishnan Rajendran
  • 11,122
  • 3
  • 31
  • 41
  • this link could help you. https://stackoverflow.com/questions/32237284/how-to-change-toolbar-color – user3678528 Aug 05 '17 at 08:55
  • `textColorSecondary` will help you. Additionally also please have a look [here](https://stackoverflow.com/questions/39070040/textcolor-vs-textcolorprimary-vs-textcolorsecondary) – oldcode Aug 05 '17 at 10:00

1 Answers1

0

Add this to style.xml

<style name="ToolBarStyle" parent="Theme.AppCompat">
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColorSecondary">@android:color/white</item>
    <item name="actionMenuTextColor">@android:color/white</item>
</style>

And Make your Widget.Toolbal like this:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        app:theme="@style/ToolBarStyle"
        android:layout_height="?attr/actionBarSize"
  />

You can change the color in <item name="actionMenuTextColor">@android:color/white</item> to whatever color you want.

Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50