开发者

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

开发者 https://www.devze.com 2023-01-06 20:24 出处:网络
The options menu has a translucent background and I would like to make it solid and non-transparent.开发者_C百科Is there a way?Try this:

The options menu has a translucent background and I would like to make it solid and non-transparent.开发者_C百科 Is there a way?


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


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.


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/


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

精彩评论

暂无评论...
验证码 换一张
取 消