androidandroid-actionbaractionbarsherlocktitletruncate

How to display android actionbar title without truncation occurring


I have an app with a reasonably long title (e.g. My Long Title App). I am using an ActionBar and noticed the app title keeps being truncated (e.g. My Long Title A...). This happens even though 2 action bar items (both marked as 'ifRoom') are displayed.

Does anyone know if there is a way to ensure the Activity Title width takes priority over 'ifRoom' action bar items (i.e. ensure my title displays in full, with action bar items moving to the dropdown menu if more room is needed)?

Many thanks people.


Solution

  • Unfortunately there is not a way to prevent truncation of the action bar title. You do, however, have some options to free up some room in your action bar.. You can either:

    1. Force your action items into the overflow menu. If you are using the latest ActionBarSherlock(4.2.0) it is much harder to do this. See this answer for a workaround when using 4.2.0. If you feel the newest version isn't required, you can use ABS 4.1.0. On 4.1.0, you just set your activity theme to @style/Theme.Sherlock.ForceOverflow. Please note that forcing the overflow menu is not recommended as it provides inconsistent navigation across apps.
    2. You can use a split action bar and force the action items into the bottom action bar. Have a look at CommonsWare's answer here. For information on the split action bar, see here.