简体   繁体   中英

Android Action Bar add all icon to overflow

I am updating my apps to have action bars, as Google seems to want developers to do now, and I am trying to get all the options of one app to all be in the overflow menu. I have searched far and wide but I can't seem to find anything that would make them do that. I'm pretty sure it would be something in the xml that defines the menu items. Do any of you guys know how to make all the menu options be in the overflow menu?

As CommonsWare said, showAsAction is the key. Set android:showAsAction="never" on the if you are inflating an xml or use item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if you are creating the items with code.

You should consider using android:showAsAction="ifRoom" or item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); since the actionbar will contain a lot of empty space, if you don't fill it with something else that is.

They will all be in the overflow menu by default. You have to specifically do things to your menu resource XML files to change that, notably have android:showAsAction attributes on the <item> elements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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