1

I am trying to color the popup menu (when clicking the overflow three vertical dots), but it doesn't work:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:popupMenuStyle">@style/MyPopupMenu</item>

        <!-- None of these work either -->
        <item name="android:windowBackground">@color/white</item>
        <item name="android:popupBackground">@color/white</item>
        <item name="android:actionModeBackground">@color/white</item>
        <item name="android:dropDownListViewStyle">@style/MyPopupMenu</item>
        <item name="android:actionBarWidgetTheme">@style/MyPopupMenu</item>
    </style>

    <!-- Popup Menu Background Color styles -->

    <!--
        I also tried parent as:
              android:Widget.Holo.Light.ListPopupWindow
              @style/Widget.AppCompat.Light.ListPopupWindow
              @android:style/Widget.Holo.ListPopupWindow
    -->
    <style name="MyPopupMenu"
    parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
    </style>

</resources>

And in my AndroidManifest.xml:

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

Why is it still showing with the default black background?

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330

1 Answers1

1

Make sure, yo have applied styles as per version based...

values.xml replace

<item name="android:popupMenuStyle">@style/MyPopupMenu</item>

to

<item name="popupMenuStyle">@style/MyPopupMenu</item>

values-14.xml

<item name="android:popupMenuStyle">@style/MyPopupMenu</item>

and try once...

Harsha Vardhan
  • 3,324
  • 2
  • 17
  • 22
  • What is the structure of values folder in your project – Harsha Vardhan Oct 11 '14 at 04:54
  • `values`, `values-land`, `values-sw600dp`, `values-v14` – Don Rhummy Oct 11 '14 at 04:56
  • Ok, then you're @style/MyPopupMenu is correct, in values-v14 – Harsha Vardhan Oct 11 '14 at 04:56
  • You were right! I forgot to change the values in `values-v14/styles.xml`! THANK YOU! Can you change your answer to that (making sure to set styles in both folders) and I'll mark it correct. – Don Rhummy Oct 11 '14 at 04:57
  • Hmm, it's not working on tablet. If I change the background for everything, then the menu background also changes. Otherwise, it won't change the menu color! Any ideas? – Don Rhummy Oct 11 '14 at 05:19
  • You're having values-sw600dp, it is for tablet add even in that – Harsha Vardhan Oct 11 '14 at 06:53
  • I found the answer and it's a weird bug. You have to first set a base theme which has the action bar parent and then make your app's theme descend from that: `` and the app's theme: `` See more here: http://www.techrepublic.com/article/style-androids-overflow-menu-using-this-sanity-saving-workaround/ – Don Rhummy Oct 11 '14 at 06:57