Item title not displayed in portrait with SHOW_AS_ACTION_WITH_TEXT

android, android-actionbar, android-contextmenu

Solution

Does anyone know what I could do to fix it ?

I doubt that you can. "Always" and "with text" are requests, not commands. The framework does not always honor either of them.

Problem

In my activity, I have an action mode with a single item which has a title and an icon. I want both the title and the icon to be displayed, so I use SHOW_AS_ACTION_WITH_TEXT and SHOW_AS_ACTION_ALWAYS flags. In landscape orientation, it's fine. I have title + icon. But in portrait orientation only the icon is displayed (though there's a lot of free space). Does anyone know what I could do to fix it ? Note that the title is correctly displayed if I remove the icon. Here is my sample code: ``` public class TestActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startActionMode(new Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.add("Item 1").setIcon(R.drawable.ic_launcher).setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); } } ```

Original source