3
votes

I customized the toolbar in my app to be dark action bar and light menu.
It all seems to be fine except for the 'selection background' of the menu items.
Here is how it looks, notice there is a light gray background (which appears on click) and the background behind the text remains white like it overrides the onClick color. (the menu is total white)
enter image description here

Here is the theme used for the toolbar :

<style name="Theme.Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:background">@color/primary_color</item>
    <item name="android:textColorPrimary">@color/primary_light</item>
</style>

<style name="Theme.Toolbar.Menu" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:background">@color/primary_light</item>
    <item name="android:textColorPrimary">@color/primary_dark</item>
    <item name="android:selectedWeekBackgroundColor">@color/primary_dark</item>
</style>

And the toolbar layout :

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:theme="@style/Theme.Toolbar"
    app:popupTheme="@style/Theme.Toolbar.Menu"/>
1

1 Answers

2
votes

In your popupTheme set

<item name="android:colorBackground">@color/your_color</item>

instead of "android:background" (and remove that completely). I found this solution at this post and it worked for me: Style appcompat-v7 Toolbar menu background