简体   繁体   English

ActionBar / ActionBarSherlock上的菜单溢出按钮

[英]Menu overflow button on ActionBar/ActionBarSherlock

This app was designed before the deprecation of the hardware menu button, so now it automatically shows a menu overflow button at the bottom of our app. 此应用是在不赞成使用硬件菜单按钮之前设计的,因此现在它会在我们应用的底部自动显示菜单溢出按钮。 We'd rather it wedge itself to the right of our 4 tab bar items when needed. 我们宁愿在需要时将其自身楔入4个标签栏项的右侧。

If that's not doable, we'd at least like to be able to center the lonely menu overflow button like it appears on the first pic here -> http://www.droid-life.com/2012/05/30/dear-developers-can-we-quit-with-the-menu-button-already-and-adopt-an-action-overflow/ 如果这不可行,我们至少希望能够将寂寞的菜单溢出按钮居中,就像它出现在第一个图片上一样-> http://www.droid-life.com/2012/05/30/dear开发人员可以退出菜单按钮,并采用一种动作溢出/

We are using ActionBarSherlock. 我们正在使用ActionBarSherlock。

You must add it mannually with setAddOptionMenu(true); 您必须使用setAddOptionMenu(true)手动添加它;

and then create it in xml for example: 然后在xml中创建它,例如:

<item
    android:id="@+id/video"
    android:title="@string/video"
    android:icon="@drawable/video"
    android:showAsAction="ifRoom|withText"
/>

<item
    android:id="@+id/email"
    android:title="@string/email"
    android:icon="@drawable/email"
    android:showAsAction="ifRoom|withText"
/>

Then inflate it 然后充气

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.items, menu);
    return super.onCreateOptionsMenu(menu);
}

if you want to split the actionBar in the bottom of the screen you can use 如果要在屏幕底部拆分actionBar,可以使用

android:uiOptions=”splitActionBarWhenNarrow” 

in your activity in the manifest 在清单中的活动中

hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM