简体   繁体   中英

Show menu item icons in actionbar while having navigation drawer

Been trying everything to show the menu item search (searchWidget) in the actionbar. I have a navigationdrawer, which doesn't hide the actionbar items at any time. But still the search item is always at the overflow, even when having a large screen device.

I have tried using always in the showAsAction in the menu item, and even putting the menu item as visible in the onPrepareOptionsMenu method, and calling it when the drawer opens and closes to see if something changed, and still nothing.

I won't post code now, just wondering if someone had the same problem. If necessary I will post code of course.

If you are using regular action bar menu items (API 13+) then you simply need to say -

android:showAsAction="always"

for that menu item in the menu resource.

However, if you are using the compat library - appcompat-v7 for action bar and menu items (API 7+) then you need your app's name as the namespace as -

yourapp:showAsAction="always"

and add the following to menu tag at the top with the android namespace as -

xmlns:yourapp="http://schemas.android.com/apk/res-auto"

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