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;




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值