我正在尝试构建一个应用了两种不同自定义字体的字符串。我已将具有相应字体的两个字符串附加到字符串生成器中,但这对字符串没有任何作用?有谁知道为什么?
private fun createSpannedNameAndComment(name: String, comment: String): SpannableStringBuilder {
val semiBoldFont = android.graphics.Typeface.create(
ResourcesCompat.getFont(
this,
R.font.josefin_san_semi_bold
), android.graphics.Typeface.NORMAL
)
val regularFont = android.graphics.Typeface.create(
ResourcesCompat.getFont(
this,
R.font.josefin_san_regular
), android.graphics.Typeface.NORMAL
)
return SpannableStringBuilder().apply {
append(name, semiBoldFont, 0)
append(" ")
append(comment, regularFont, 0)
}
}