MenuItem is the element on Actionbar, and many of the UI design is used with this control.
Use:
1. Writing Menu.xml resource files
<span style= "FONT-SIZE:14PX;" ><menu xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http// Schemas.android.com/apk/res-auto " xmlns:tools=" Http://schemas.android.com/tools " tools:context=". Mainactivity "> <item android:id=" @+id/action_inbox " android:icon=" @mipmap/ic_inbox_white " android:title= "Inbox" app:showasaction= "Always"/></menu></span>
you can set the icon file, but the display may not be very good.
Showasaction representative whether in Actinbar, commonly used always,ifroom,never;
2. Load in action:
<span style= "FONT-SIZE:14PX;" > @Override Public boolean oncreateoptionsmenu (Menu menu) { getmenuinflater (). Inflate (r.menu.menu_ Main, menu); return true; } </span>
Note that you can customize the properties of a button, just as you would a custom control,
First write the layout file:
<span style= "FONT-SIZE:14PX;" ><?xml version= "1.0" encoding= "Utf-8"? ><imagebutton xmlns:android= "Http://schemas.android.com/apk/res /android " android:layout_width="? attr/actionbarsize " android:layout_height="? attr/actionbarsize " android:background= "@drawable/btn_default_light" android:src= "@mipmap/ic_inbox_white"/></span>
then just add a few lines of code to the Oncreatemenu () method of the action, locate the Actionitem, and then call the Setactionview () method.
<span style= "FONT-SIZE:14PX;" > @Override Public boolean oncreateoptionsmenu (Menu menu) { getmenuinflater (). Inflate (r.menu.menu_ Main, menu); Inboxmenuitem = Menu.finditem (r.id.action_inbox); Inboxmenuitem.setactionview (R.layout.menu_item_view); return true; } </span>
Use details and optimization of the MenuItem on the Android-actionbar