I have an ellipsis in the title of action bar on my android application even though the length is well within 10-15 chars. I am using Navigation Drawer and it works fine but after a few switches it adds ellipsis to the title.
I have not used any custom xml to format my action bar. How do I remove that ellipsis ? What style/option should I use to make sure it never ellipsize the title ?
Slightly different/simpler but following the same idea that worked for me:
...
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
getActivity().setTitle(title);
}
});
...
Simplifying Simon's answer, you can just override the setTitle
method of your activities with this:
@Override
public void setTitle(final CharSequence title) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
MyActivity.super.setTitle(title);
}
});
}
I do this in a ParentActivity that is extended by all the Activities of my application.
I have had this same problem. There is plenty of room but the TextView that holds the title text does not change size to fit its new textual content. This solves my problem:
protected Handler mUiHandler = new Handler(Looper.getMainLooper());
protected void setActionBarTitle(final CharSequence title, final boolean showHomeAsUp)
{
mUiHandler.post(new Runnable()
{
@Override
public void run()
{
Activity activity = getActivity();
if(activity != null){
ActionBar ab = activity.getActionBar();
ab.setDisplayHomeAsUpEnabled(showHomeAsUp);
ab.setDisplayShowTitleEnabled(false);
activity.setTitle(title);
ab.setDisplayShowTitleEnabled(true);
}
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With