2

Is there a way (perhaps some special character along the lines of non-breaking spaces) that I can force the menu items in my Action Bar to have two line labels? I think this just looks better than long, single-line tab labels...

Thanks,
R.

Edit, additional info: My apologies, I have so far managed to avoid needing the overflow menu, probably because I'm developing for a Nexus 7 with a nice large screen. To clarify, one of my menu tabs (in the action bar proper) is "Restore Defaults", but I think it would look better if it was:

Restore
Defaults

Is there something I can incorporate into my Strings.xml file to force the Action Bar to display the item like that? When I used longer names for all five menu items, "Restore Defaults" DID display on two lines (but it was the only one). Anyway, I know it's possible, just not how to do it on purpose.

Rich
  • 4,157
  • 5
  • 33
  • 45
  • Still trying to fit the square in the disc? ;=) http://stackoverflow.com/questions/12942160/not-too-happy-with-the-android-action-bar-how-can-i-reduce-its-size – Vincent Mimoun-Prat Oct 17 '12 at 20:47
  • Nope. Actually, that's working just fine -- this is a separate issue. – Rich Oct 17 '12 at 20:48
  • 1
    It is unclear what you are referring to here. Once, you use the term "menu items", but that could either be items in the action bar proper or ones relegated to the overflow menu. In another place, you use the term "tab labels", suggesting that you are referring to tabs in the action bar. – CommonsWare Oct 17 '12 at 20:54
  • 5
    Insert a '\n' in the title of your menu item. that should make it wrap – toadzky Oct 17 '12 at 21:07
  • Toadzky: Please make this an answer so I can accept it!! Thanks. – Rich Oct 17 '12 at 21:13
  • See here: http://stackoverflow.com/questions/11259311/action-bar-title-with-more-than-one-line – Mr-IDE Feb 14 '13 at 21:07

1 Answers1

5

Since toadzky does not make an answer of his comment, I will:

Insert a '\n' in the title of your menu item. that should make it wrap.

As soon as he puts it up as an answer, I will delete mine and you can accept his, but this way at least the question can be officially closed.

MarchingHome
  • 1,184
  • 9
  • 15
  • Thanks. I know it seems like it, and it kinda is. But as I said, I will delete it as soon as toadzky claims the rep. Until that moment, somebody has to do it :) – MarchingHome Oct 17 '12 at 21:48
  • Way to take one for the team!! – Rich Oct 17 '12 at 22:22
  • 3
    "\n" does not work, seem it is replaced space. Could you share the code? Tried the following, not work: This is a\nlong name item PopupMenu popup = new PopupMenu(getActivity(), v); popup.getMenu().add(Menu.NONE, id, Menu.NONE, getResources().getString(R.string.long_name_menuitem)); or or define the menuItem – lannyf Aug 25 '15 at 19:03
  • You can use ` ` simply :) – GreenROBO Aug 26 '15 at 05:26
  • '\n' is not creating the desired second line. The UI is using the **...** ellipses to truncate. `` – AdamHurwitz Nov 04 '18 at 17:57