I posted a similar question regarding my code compiling but I managed to get everything running. However, my code doesn't change the default white background to a darker color. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme">
<item name="@android:panelFullBackground">@android:color/background_dark</item>
<item name="@android:panelColorBackground">@android:color/background_dark </item>
<item name="@android:panelBackground">@android:color/background_dark</item>
</style>
</resources>
I'm applying the theme here:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Theme">
<item android:id="@+id/add"/>......
</menu>
Edit: Here is the output from the logcat
01-10 05:47:08.434: E/AndroidRuntime(30489): FATAL EXCEPTION: main
01-10 05:47:08.434: E/AndroidRuntime(30489): android.content.res.Resources$NotFoundException: Resource ID #0x0
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.content.res.Resources.getValue(Resources.java:901)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.content.res.Resources.getDrawable(Resources.java:589)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:500)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:703)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1475)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1845)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2758)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2730)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.view.ViewRoot.handleMessage(ViewRoot.java:1999)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.os.Looper.loop(Looper.java:150)
01-10 05:47:08.434: E/AndroidRuntime(30489): at android.app.ActivityThread.main(ActivityThread.java:4385)
01-10 05:47:08.434: E/AndroidRuntime(30489): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 05:47:08.434: E/AndroidRuntime(30489): at java.lang.reflect.Method.invoke(Method.java:507)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
01-10 05:47:08.434: E/AndroidRuntime(30489): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
01-10 05:47:08.434: E/AndroidRuntime(30489): at dalvik.system.NativeStart.main(Native Method)
Add this to the activity you want to change the menu appearance for:
Instead of setting that theme to
MenuItem
, try setting this theme to yourApplication
tag inAndroidManifest.xml
like this:Add a parent in style when defining
"Theme"
instyles.xml
like this:Edit: this is working for me try to change colors
It appears that
android:panelBackground
should be a drawable, not a color.A good place to start would probably be locating Android's default nine-patch in the SDK's platform resources (
menu_hardkey_panel_holo_dark.9.png
), copying them to your own drawable folders and editing them. Finally, as Adil pointed out, add the items to the style declaration as:(Note that here I'm using ActionBarSherlock, hence the parent theme.)