道歉,如果这似乎很明显。我想使用.ttf
字符串将警报对话框标题的字体设置为与Spannable
文件匹配。但是我正在检索一个无法解析的构造函数
(TypefaceSpan(android.graphics.'Typeface'))错误。
代码:
Typeface customFont;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
customFont = Typeface.createFromAsset(getAssets(), "fonts/pacifico_regular.ttf");
...
questionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SpannableString title = new SpannableString("HOW TO USE THE APP");
title.setSpan(new TypefaceSpan(customFont),
0, title.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}