How to display android actionbar title without truncation occurring

This bug is caused when the last title is smaller than the new one, therefore the trick is to make the last title always longer than the new setTitle.

Even in Google Issue Tracker there is no solution and the issue status is now Obsolete.

Update : (Workaround)

getSupportActionBar().setTitle("");

getSupportActionBar().setTitle(title);

I was having this problem with very short action bar titles. The action bar title would get truncated with ellipses even with 5-6 character strings.

If you have a short title (say, "Shop"), then call ActionBar.setTitle(<inputString or resId>) where the input string is longer than the previous title, the TextView will not resize itself to give your new title room, even if the ActionBar has plenty of space.

Before (ShortTitle)

short title, before

// now call setTitle() with a longer title
ActionBar actionBar = getActionBar();
actionBar.setTitle("Collin");

After (ShortTitle)

longer title, after

Solution

Move your setTitle() call on onCreateOptionsMenu()

result:

enter image description here


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.