Fixed
Status Update
Comments
ng...@google.com <ng...@google.com> #2
Yep, that's exactly my problem at the moment. In our app everything is red, grey and
white. Orange is not a good combination.
white. Orange is not a good combination.
ng...@google.com <ng...@google.com> #3
Thats exactly my problem is.
If any one got the solution please mail me.
If any one got the solution please mail me.
gn...@gmail.com <gn...@gmail.com> #4
Did you find a solution to customize the option menu ?
ng...@google.com <ng...@google.com> #5
To set a custom background on menu item you can use this tip:
http://pastebin.com/1QHGTMUW
call the setMenuBackground in the onCreate
call the setMenuBackground in the onCreate
[Deleted User] <[Deleted User]> #6
solution from rciov work with Android 1.6, 2.1 and 2.2 but don't work with 2.3 :
InflateException android.view.InflateException: Binary XML file line #17: Error inflating class com.android.internal.view.menu.IconMenuItemView
Unfortunately I don't see new function in 2.3 to override default behavior.
InflateException android.view.InflateException: Binary XML file line #17: Error inflating class com.android.internal.view.menu.IconMenuItemView
Unfortunately I don't see new function in 2.3 to override default behavior.
ni...@commercetools.com <ni...@commercetools.com> #7
Yes, unfortunatly i saw that it doesn't work on 2.3...
[Deleted User] <[Deleted User]> #8
That's what happens when you rely on APIs and class names that are not public.
Note: com.android.*INTERNAL*.view...
This problem is unrelated to this bug.
Note: com.android.*INTERNAL*.view...
This problem is unrelated to this bug.
ng...@google.com <ng...@google.com>
ki...@persosa.com <ki...@persosa.com> #9
Yes, of course. You are right :)
[Deleted User] <[Deleted User]> #11
[Comment deleted]
[Deleted User] <[Deleted User]> #12
If this helps, here is how I've been working around limitations with the built-in options menus.
http://www.codeproject.com/KB/android/AndroidMenusMyWay.aspx
si...@gmail.com <si...@gmail.com> #13
Here is a less nasty, better-documented refinement of the hacks above that works on 2.1, 2.2, and 2.3 and is unlikely to do harm on 3.X (but one can never guarantee). See post from "Louis Semprini:"
Google, this is clearly a COMMON requirement from developers---PLEASE provide a documented, supported way to set Options Menu:
- background, AND
- text color
In Android 2.X there is a nearly-undocumented style android:panelFullBackground but it only works for the background color, not the text. That doesn't help if you want to change the background from white to black or v/v.
Many developers need to do this so the Options Menu matches the visual style of the rest of their app. The Android documentation and Android engineers on the dev list in multiple places consistently state that Android apps should not rely on the (manufacturer-themable) look of the stock UI since themes may vary widely on different devices. Well, this is a case where we don't have control over the look of a key interface item.
Any real solution may also need to address Action Bar buttons for >= 3.X tablet devices, though I don't have experience with those yet so I can't comment.
Some developers have resorted to completely displacing the Android Options Menu and doing their own. This seems overkill; all the developers need is to set the colors and text like one normally does for a Button or other Android-provided resource!
If you need any evidence that this is a common requirement, please check out these links:
Thanks!
or...@gmail.com <or...@gmail.com> #14
Mee too.
li...@gmail.com <li...@gmail.com> #15
That generates java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
or...@gmail.com <or...@gmail.com> #16
agree, 06-18 E/AndroidRuntime(5594): java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
Any real solution to this?
Any real solution to this?
ja...@google.com <ja...@google.com> #17
[Comment deleted]
ma...@thebishops.org <ma...@thebishops.org> #18
[Comment deleted]
ja...@google.com <ja...@google.com> #19
Just ran into this issue too, on an App that had to be compatible with Gingerbread and still retain as much of the styling from Holo-enabled devices as possible.
I found a relatively clean solution, that worked OK for me.
In the theme I use a 9-patch drawable background to get a custom background color:
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="android:panelFullBackground">@drawable/menu_hardkey_panel</item>
</style>
I gave up trying to style the text color, and just used a Spannable to set the text color for my item in code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.actions_livejazz, menu);
if (android.os.Build.VERSION.SDK_INT <
android.os.Build.VERSION_CODES.HONEYCOMB) {
SpannableStringBuilder aboutText = new SpannableStringBuilder();
aboutText.append(getString(R.string.about_action));
aboutText.setSpan(new ForegroundColorSpan(Color.WHITE),
0, aboutText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
MenuItem aboutItem = menu.findItem(R.id.action_about);
aboutItem.setTitle(aboutText);
}
return true;
}
I found a relatively clean solution, that worked OK for me.
In the theme I use a 9-patch drawable background to get a custom background color:
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="android:panelFullBackground">@drawable/menu_hardkey_panel</item>
</style>
I gave up trying to style the text color, and just used a Spannable to set the text color for my item in code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.actions_livejazz, menu);
if (android.os.Build.VERSION.SDK_INT <
android.os.Build.VERSION_CODES.HONEYCOMB) {
SpannableStringBuilder aboutText = new SpannableStringBuilder();
aboutText.append(getString(R.string.about_action));
aboutText.setSpan(new ForegroundColorSpan(Color.WHITE),
0, aboutText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
MenuItem aboutItem = menu.findItem(R.id.action_about);
aboutItem.setTitle(aboutText);
}
return true;
}
ja...@google.com <ja...@google.com> #20
I will also like to have a easy way to modify the background and text color of options Menu. Currently there exists none and it is really painful to implement a custom options menu
dh...@gmail.com <dh...@gmail.com> #21
Here is a super-hack, non-future proof, way to apply you own themes to the panel menu.
This seems to work in the emulator, on other devices, who knows.
Override the panel backgrunds:
<style name="MyAppTheme" parent="@android:style/Theme.Light">
<item name="android:panelBackground">@drawable/menu_background</item>
<item name="android:panelFullBackground">@drawable/menu_background_fill_parent_width</item>
</style>
Create your own themes for Theme.IconMenu and Theme.ExpandedMenu to style text color, etc:
<style name="Theme.IconMenu" parent="@android:style/Theme.Light">
<!-- Menu/item attributes -->
<item name="android:itemTextAppearance">@android:style/TextAppearance.Widget.IconMenu.Item</item>
<item name="android:itemBackground">@android:drawable/menu_selector</item>
<item name="android:itemIconDisabledAlpha">?android:attr/disabledAlpha</item>
<item name="android:horizontalDivider">@android:drawable/divider_horizontal_dark</item>
<item name="android:verticalDivider">@android:drawable/divider_vertical_dark</item>
<item name="android:windowAnimationStyle">@android:style/Animation.OptionsPanel</item>
<item name="android:moreIcon">@android:drawable/ic_menu_more</item>
<item name="android:background">@null</item>
</style>
<style name="Theme.ExpandedMenu" parent="@android:style/Theme.Light">
<!-- Menu/item attributes -->
<item name="android:itemTextAppearance">?android:attr/textAppearanceLarge</item>
<item name="android:listViewStyle">@android:style/Widget.ListView.Menu</item>
<item name="android:windowAnimationStyle">@android:style/Animation.OptionsPanel</item>
<item name="android:background">@null</item>
</style>
Copied from:
http://code.google.com/p/android-source-browsing/source/browse/core/res/res/values/themes.xml?repo=platform--frameworks--base&name=gingerbread
You'll have to import a few private resources and remove the android:prefix, or apply you own style.
Then, in you Activity:
@Override
public boolean onCreatePanelMenu (int featureId, Menu menu) {
if ( Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
&& featureId == Window.FEATURE_OPTIONS_PANEL) {
try {
final Field field = menu.getClass().getDeclaredField("THEME_RES_FOR_TYPE");
field.setAccessible(true);
final int[] THEME_RES_FOR_TYPE = (int[])field.get(menu);
THEME_RES_FOR_TYPE[0] = R.style.Theme_IconMenu;
THEME_RES_FOR_TYPE[1] = R.style.Theme_ExpandedMenu;
}
catch (Exception e) {
// ignore
}
}
return super.onCreatePanelMenu(featureId, menu)
}
This seems to work in the emulator, on other devices, who knows.
Override the panel backgrunds:
<style name="MyAppTheme" parent="@android:style/Theme.Light">
<item name="android:panelBackground">@drawable/menu_background</item>
<item name="android:panelFullBackground">@drawable/menu_background_fill_parent_width</item>
</style>
Create your own themes for Theme.IconMenu and Theme.ExpandedMenu to style text color, etc:
<style name="Theme.IconMenu" parent="@android:style/Theme.Light">
<!-- Menu/item attributes -->
<item name="android:itemTextAppearance">@android:style/TextAppearance.Widget.IconMenu.Item</item>
<item name="android:itemBackground">@android:drawable/menu_selector</item>
<item name="android:itemIconDisabledAlpha">?android:attr/disabledAlpha</item>
<item name="android:horizontalDivider">@android:drawable/divider_horizontal_dark</item>
<item name="android:verticalDivider">@android:drawable/divider_vertical_dark</item>
<item name="android:windowAnimationStyle">@android:style/Animation.OptionsPanel</item>
<item name="android:moreIcon">@android:drawable/ic_menu_more</item>
<item name="android:background">@null</item>
</style>
<style name="Theme.ExpandedMenu" parent="@android:style/Theme.Light">
<!-- Menu/item attributes -->
<item name="android:itemTextAppearance">?android:attr/textAppearanceLarge</item>
<item name="android:listViewStyle">@android:style/Widget.ListView.Menu</item>
<item name="android:windowAnimationStyle">@android:style/Animation.OptionsPanel</item>
<item name="android:background">@null</item>
</style>
Copied from:
You'll have to import a few private resources and remove the android:prefix, or apply you own style.
Then, in you Activity:
@Override
public boolean onCreatePanelMenu (int featureId, Menu menu) {
if ( Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
&& featureId == Window.FEATURE_OPTIONS_PANEL) {
try {
final Field field = menu.getClass().getDeclaredField("THEME_RES_FOR_TYPE");
field.setAccessible(true);
final int[] THEME_RES_FOR_TYPE = (int[])field.get(menu);
THEME_RES_FOR_TYPE[0] = R.style.Theme_IconMenu;
THEME_RES_FOR_TYPE[1] = R.style.Theme_ExpandedMenu;
}
catch (Exception e) {
// ignore
}
}
return super.onCreatePanelMenu(featureId, menu)
}
Description
A way that is command-line and/or web-based - don't want to store some env var values in a file
Please see/like/respond at