Question

I have a menu, which contain an item with an icon that comes with sdk (from skd/platform/...). In ICS it's displayed fine (dark action bar, light color icon), but in android 2.2, you can't see the icon because the default theme is white and so is the icon. Is there a way to access android default icons, like when using the search bar, the icon is displayed correctly on all android versions? Is there a way to access android default icons?

Was it helpful?

Solution

If you are defining your menu in an XML, then something like this will ensure the icons are always picked up from the corresponding SDK drawables.

<item
    android:id="@+id/menuID"
    android:icon="@android:drawable/ic_menu_add"
    android:showAsAction="always"
    android:title="Some Label">
</item>

If you are adding your Menu Items in your Java code, something like this should do it:

menu.add(1, 1, 1, "Some Label").setIcon(android.R.drawable.ic_menu_add);

Note: You should check if the icons you intend to use are common across all platforms to ensure a uniform and error free functioning for your users.

OTHER TIPS

Yes here os a menu item using the android preferences/settings icon as it's icon.

<item
    android:id="@+id/menu_settings"
    android:icon="@android:drawable/ic_menu_preferences"
    android:orderInCategory="100"
    android:showAsAction="always|withText"
    android:title="@string/menu_settings"/>

For a full list of the icons look at the documentation for the R.drawable class.

http://developer.android.com/reference/android/R.drawable.html

For an app that views all of the icons see How to preview R.drawable.* images

First add actionOverFlowButtonStyle into your main theme

 <style name="AppTheme" parent="AppBaseTheme">

        <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    </style>

Define the New style for action over flow button

<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_menu</item>
</style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top