It seems to me that this is not possible with themes and styles, but I found a workaround for setting the ellipsis value at runtime.
The most difficult thing is to find the text (or subtitles) of the TextView, because the identifier of this view is in the internal android package.
So you need to create a stub class in your project
package com.android.internal; public class R { public static final class id { public static int action_bar_title = 0; public static int action_bar_subtitle = 0; } }
After that, you need to find this view in the code (I do it with the following code, it works with sherlock as well as with default files)
public class ActionBarUtils { public static TextView getActionbarTitle(Activity activity) { TextView title = (TextView) activity.findViewById(R.id.abs__action_bar_title);
Now you can set the ellipsis value in the operation code:
getActionBarTitle().setEllipsize(TextUtils.TruncateAt.MIDDLE)
PS: Make sure you call getActionBarTitle when the header is visible (after calling setDisplayShowTitleEnabled (true)), otherwise you will get a NullPointerException.
PPS: If you are using obfuscation proguard, you should add to proguard.cfg:
-keep class com.android.internal.R*{ *; }
source share