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標題字體嗎?或者我必須轉向一種新方法?