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.
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:
@style/Theme.Sherlock.ForceOverflow
. Please note that forcing the overflow menu is not recommended as it provides inconsistent navigation across apps.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)
I am not sure if there is a straightforward way but there are multiple workarounds.
1) You can force the bar to get to the bottom and save space:
How can I force the Action Bar to be at the bottom in ICS?
http://developer.android.com/guide/topics/manifest/application-element.html
2) Set a title with custom font: https://stackoverflow.com/a/8748802/1276103
3) You can set the title over two lines: https://stackoverflow.com/a/18867068/1276103
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, theTextView
will not resize itself to give your new title room, even if theActionBar
has plenty of space.Before (ShortTitle)
After (ShortTitle)
Solution
Move your
setTitle()
call ononCreateOptionsMenu()
result: