Is it possible to make the Android options menu background non-translucent?

后端 未结 4 989
无人共我
无人共我 2020-12-06 19:00

The options menu has a translucent background and I would like to make it solid and non-transparent. Is there a way?

相关标签:
4条回答
  • 2020-12-06 19:03

    Try this for android 4.0:

    <style name="MyTheme" parent="@android:style/Theme.DeviceDefault">       
            <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
        </style>
    
        <style name="MyPopupMenu" parent="@android:style/Widget.DeviceDefault.ListPopupWindow">
            <item name="android:popupBackground">{your color or drawable}</item>
        </style>
    

    Also, the following site generate Action Bar Style :

    http://jgilfelt.github.com/android-actionbarstylegenerator/

    0 讨论(0)
  • 2020-12-06 19:05

    If you don't want to style a whole theme and just change the options menu background then set the panelFullBackground property to a DRAWABLE RESOURCE of your liking. Setting it to a color directly doesn't work so either make one coloured - 9patch, if you want to save in size -image and set it to that or make a couple and make a selector drawable with an image for each state.

    I put my definition in a style that i use for all the activities in my project using:

    @drawable/optionsmenu_back

    optionsmenu_back being a 9patch image with a solid colour...

    0 讨论(0)
  • 2020-12-06 19:09

    set android:theme="myTheme", and define your own theme with whatever colours you want. Read up about Styles, and look at the android themes.xml.

    0 讨论(0)
  • 2020-12-06 19:21

    Try this:

    <style name="MyTheme" parent="android:Theme">
         <item name="android:panelFullBackground">{your color or drawable}</item>
    </style>
    

    Also, see:

    • http://code.google.com/p/android/issues/detail?id=4441
    • How to change the background color of the options menu?
    • Completely overriding menu panel: Android MenuItem Toggle Button
    0 讨论(0)
提交回复
热议问题