menu中的顯示問題

menu的顯示方式

boolean android.app.Activity.onCreateOptionsMenu(Menu menu)

MenuItem actionItem = menu.add("Action Button");
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

setShowAsAction:設置ActionBar中menu的顯示方式

/** 從不顯示。Never show this item as a button in an Action Bar. */
public static final int SHOW_AS_ACTION_NEVER = 0;
/** 
*<span style="line-height: 25.2px; font-family: Helvetica, Tahoma, Arial, sans-serif;">有空間就顯示。</span>
*Show this item as a button in an Action Bar if the system decides there is room for it. */
public static final int SHOW_AS_ACTION_IF_ROOM = 1;
/**
* 總是顯示
*Always show this item as a button in an Action Bar.
* Use sparingly! If too many items are set to always show in the Action Bar it can
* crowd the Action Bar and degrade the user experience on devices with smaller screens.
* A good rule of thumb is to have no more than 2 items set to always show at a time.
*/
public static final int SHOW_AS_ACTION_ALWAYS = 2;

/**
<span style="font-family:Helvetica, Tahoma, Arial, sans-serif;">*</span><span style="font-family:Helvetica, Tahoma, Arial, sans-serif;">顯示時跟誰文字</span><span style="font-family:Helvetica, Tahoma, Arial, sans-serif;">
* When this item is in the action bar, always show it with a text label even if
* it also has an icon specified.
*/
public static final int SHOW_AS_ACTION_WITH_TEXT = 4;

/**</span>
*默認收縮其 action view
* This item's action view collapses to a normal menu item.
* When expanded, the action view temporarily takes over
* a larger segment of its container.
*/
public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8;




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章