0

How do we customize the font style of title of action bar. The font's style is also customized and has to be imported into the application ?

  • 1
    possible duplicate of [How to Set a Custom Font in the ActionBar Title?](http://stackoverflow.com/questions/8607707/how-to-set-a-custom-font-in-the-actionbar-title) – 2Dee Oct 28 '14 at 08:50
  • BTW, I found that duplicate typing "custom font actionbar" in Google. I'm still wondering how come you didn't ... – 2Dee Oct 28 '14 at 08:56

1 Answers1

7

Try this one:

    SpannableString s = new SpannableString("My Title");
    s.setSpan(new TypefaceSpan(this, "MyTypeface.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Update the action bar title with the TypefaceSpan instance
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);

Hope it helps

Reference

UPD: The source code of custom TypefaceSpan is here

krossovochkin
  • 12,030
  • 7
  • 31
  • 54