ActionBar/Menu default icons

╄→尐↘猪︶ㄣ 提交于 2019-12-06 07:57:29

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.

Justin Mclean

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!