0
在我研究的过程中,我发现了一个很好的解决方案,使用TypefaceSpan
在ActionBar标题字体中设置自定义字体。事实上,这是第二个也是投票最多的答案here。该代码看起来是这样的:使用TypefaceSpan设置ActionBar标题字体
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);
看起来不错,但所谓的TypefaceSpan
本例中使用不再exisits构造函数中,检查this,只有两个构造函数为:
public TypefaceSpan(String family)
和
public TypefaceSpan(Parcel src)
我还可以使用新的构造函数来设置新的构造函数的ActionBar标题字体吗?或者我必须转向一种新方法?