Search code examples
androidandroid-actionbarandroid-actionbar-compat

Getting actions in action bar to fill the whole bar


I'm using the support library for the action bar. I have a bunch of menu items that have showAsAction set to ifRoom. However, they only seem to occupy about half of the action bar . My action bar has no title so I was wondering if there's a way to get the actions to occupy more (all?) of the action bar. It looks as if there's some space reserved for the title.

I tried setDisplayShowTitleEnabled(false) but no luck. Also tried adding a custom view of size 0/0, but that still didn't work.


Solution

  • For future reference, here's the solution I ended up settling on: have all the items in the menu set to ifRoom and then, when inflating the menu, doing some calculations to force some of them to be always instead.

    In the calculations, I took the width of the screen in dp, then subtracted estimated values for the icon, the title/subtitle section, and then for each of the action items in the menu. Final solution ended up working pretty well.