I have the same standard options menu, but I want to change the background of the items from white to black. I've seen many postings about how to do it, but those don't work for 2.3.
Does anyone know of a working menu inflater with a custom-colored background compatible with version 2.3?
**ATTENTION** NO IMAGE PLACEMENT!!! NO CODE FROM OTHER POSTINGS, BECAUSE IVE TRIED THEM ALL HERE!!!
See if following solution solves your problem....
AndroidMenifest.xml
menu/options.xml
styles.xml
StackoverflowActivity.java
i have used the code as shown below on 2.3.1 version and it works and just call in onCreat method addOptionsMenuHackerInflaterFactory();
the output for backround blue and textcolor red as shown below
i was searching for the same stuff but when i installed my application in my Samsung galaxy Y which is having version 2.3.6 . i got black background for optionmenu automatically.although the emulator displays me white background for same menu.i don't know how it is working like that,but i got what i want.so i left it unaltered.
Here is the code:
I found this funny post from codeproject. You can custom everything you want: bk color, icon. And you can change the menu style with this:
Note: it is a trick to add view look like option menu. Hope this help!
The below code is working fine 2.3.6(test on device and emulator). It is almost copied & combined from different sites from google search
In an ideal scenario, you shouldn't be doing that. Various devices would have different colors, as they decide. If you really really have to customize the menu item's backgrounds, then, I would suggest don't use it. Instead, create some kind of context menu, which you can fully customize as per your needs.
I know its probably not a solution you are asking for, but whatever workarounds you will be be doing for this, it might work for a few device, and would probably be a disaster for others.