Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text never appears with icons in portrait mode on SherlockActionBar

I have a question regarding sherlock actionbar. In portrait mode, ICS doesn't display text next to menu items in the action bar, no matter how much space is available. Rotating to landscape mode yields the expected behavior (icons + text). If I remove the icon from the menu item, it displays the text (only) in portrait mode. Is it possible to display text + icon in portrait mode if space available? I use the code below to add menu items into actionbar.

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    menu.add(Menu.NONE, 1, 0, "Post").setTitle("Post").setIcon(android.R.drawable.ic_menu_save).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);    

    return true;
}

Thanks in advance.

like image 630
HaDenG Avatar asked Aug 15 '12 09:08

HaDenG


1 Answers

From https://github.com/JakeWharton/ActionBarSherlock/issues/400:

You will never see both the icon and text on small views on any screen with a width less than 480dp. That is a rule from the native action bar.

So, no, its not possible on smaller screens even if there is room in the action bar. As you've pointed out though, you can drop the icon to force the text to appear.

like image 143
Chris Knight Avatar answered Sep 30 '22 16:09

Chris Knight