以程序的形式设置 Typeface,在 xml 中设置 text style

我在 xml 中定义了一个 textview,现在以程序化的方式设置 Typeface:

textView.setTypeface(APP_FONT_REGULAR); //在assests (.ttf file) 中自定义字体

现在我在 xml 中设置了android:textStyle="bold"
但是为什么没有应用粗体字?
如何应用自定义的 Typface 并把它设置为粗体字?

当调用 setTypeface() 你可以设置外观:

textView.setTypeface(APP_FONT_REGULAR, Typeface.BOLD);

设置完字体以后再加上下面一段:

SpannableStringBuilder style = new SpannableStringBuilder(textView.getText().trim());
style.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, style.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
textView.setText(style);