2
votes

My popum menu has a black background theme color when i click on an item in my action bar. I would like to change the theme of my popup menu to have a holo light (white) color.

How can i do this?

Here is my style.xml file, which is empty for the moment :

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.



    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.



        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">

        <!-- All customizations that are NOT specific to a particular API-level can go here. -->

    </style>

</resources>

And extract of manifest :

<application
        android:name="com.app.ccccccc.activities.cccccccc"
        android:hardwareAccelerated="true"
        android:allowBackup="true"
        android:icon="@drawable/ic_action_blob"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
2

2 Answers

3
votes

On the onClick of the action menu you can programatically write the code for setting the background color.

or use,

<style name="AppTheme" parent="android:Theme.Light">
    <item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
</style>

manifest.xml:

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
.............
</application>
1
votes

Try editing your styles.xml as follows:

In your base theme:

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    ...
    <item name="android:popupMenuStyle">@style/PopupMenuStyle</item>
</style>

Then define PopupMenuStyle like this:

<style name="PopupMenuStyle" parent="android:Widget.Holo.Light.PopupMenu">
    <item name="android:popupBackground">@android:color/white</item>
</style>

Note that the default popup menu styles don't set the background to a solid color like I've done above, but rather use a state list drawable with a 9-patch background to provide a drop-shadow, etc.