Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar - Light Title and Light menu

I am currently working on an application that implements the Appcompat Toolbar. Now my problem is that if I choose a Light Actionbar as base, the Menu is white and the title is black. I want both to be white. If I change to Dark Actionbar as base, the Text is white, but the menu goes dark.

Here's a screenshot:

enter image description here

I just want the title text color to be white.

Here's my styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorAccent">@color/accent</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
</style>


</resources>

And here's the toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"/>

I hope You can help me. Thanks in advance!

like image 879
user2410644 Avatar asked Dec 20 '14 13:12

user2410644


2 Answers

Add this to your toolbar element

<!-- dark toolbar -->
<item name="android:theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<!-- light popup -->
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
like image 62
Eugen Pechanec Avatar answered Oct 19 '22 05:10

Eugen Pechanec


You just need to add below style in your style.xml for choosing which ever color you want, please change color as per your requirements :

<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
    <!-- Used to for the title of the Toolbar -->
    <item name="android:textColorPrimary">#fff</item>
    <!-- Used to for the title of the Toolbar when parent is Theme.AppCompat.Light -->
    <item name="android:textColorPrimaryInverse">#fff</item>
    <!-- Used to color the text of the action menu icons -->
    <item name="android:textColorSecondary">#fff</item>
    <!-- Used to color the overflow menu icon -->
    <item name="actionMenuTextColor">#fff</item>
    <!-- Color of the Toolbar -->
    <item name="android:background">#455a64</item>
</style>

And make sure to add this property to your toolbar :

app:theme="@style/MyToolbarStyle"
like image 24
Abhinav Puri Avatar answered Oct 19 '22 05:10

Abhinav Puri