0

While I was researching, I found an excellent solution to setting a custom font in the ActionBar title font using TypefaceSpan. It is in fact, the second and most voted answer here. The code would look something like:

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);

Looks good, but supposedly, the constructor of TypefaceSpan used in the example no longer exisits, checking this, the only two constructors are:

public TypefaceSpan(String family) 

and

public TypefaceSpan(Parcel src) 

Can I still use the new constructors to set ActionBar title fonts with the new constructors? Or do I have to move on to a new method?

Community
  • 1
  • 1
James Parsons
  • 6,097
  • 12
  • 68
  • 108

1 Answers1

1

Actually that constructor came from the custom TypefaceSpan class. You can copy the public class TypefaceSpan extends MetricAffectingSpan class from the answer (in the second box) to your class, and use it as the constructor.

Kharda
  • 1,318
  • 14
  • 23