0

I'm trying to make the background colour in my overflow menu different from that of my toolbar.

At present it is like this:

enter image description here

Before someone marks this as duplicate: I've tried so many things, suggestions from SO like:

How to change the background color of the options menu?

How to change background color of overflow menu (popup Menu) for action bar

How to change the background color of the overflow menu in android

but nothing is working for me. The overflowmenu is still blue. Right now my code looks like this:

The toolbar in my activity:

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

My styles.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
<!-- Customize your theme here. -->
<style name="CustomToolbarStyle" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:background">@color/colorPrimary</item>
</style>

<!-- Menu item theme here. -->
<style name="CustomPopupStyle" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:popupMenuStyle">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>

<style name="AppTheme.PopupOverlay" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="android:colorBackground">@color/colorAccent</item>

</style>
<style name="ThemeOverlay.MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:itemBackground">@color/colorAccent</item>
    <item name="android:textColor">@color/colorPrimaryDark</item>
</style>

My colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <drawable name="color_one">#FF9DEFDA</drawable>
    <drawable name="color_two">#FF9DEFDA</drawable>
    <drawable name="color_three">#ffcbcbcb</drawable>
    <drawable name="color_four">#ff0000</drawable>
    <drawable name="color_five">#ff0000</drawable>
    <drawable name="color_six">#ffffffff</drawable>
    <drawable name="color_seven">#FBAE9E</drawable>

    <color name="colorPrimary">#0A7FDA</color>
    <color name="colorPrimaryDark">#000000</color>
    <color name="colorAccent">#ece6e8</color>


    <color name="list_divider">#d9d9d9</color>
    <color name="list_row_start_color">#ffffff</color>
    <color name="list_row_end_color">#ffffff</color>
    <color name="list_row_hover_start_color">#1871EF</color>
    <color name="list_row_hover_end_color">#1871EF</color>
    <color name="color_seven">#FBAE9E</color>

</resources>

Any ideas how I can fix this problem? Tx.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
CHarris
  • 2,693
  • 8
  • 45
  • 71

1 Answers1

1

Add This style in your Style.xml And after set it in your ToolBar

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" >
        <item name="android:textColorSecondary">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@android:color/white</item>
    </style>

And in Activity

<android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    app:popupTheme="@style/AppTheme.PopupOverlay" >
Divyesh
  • 66
  • 4