如何解决通过数据绑定适配器更改字体时的奇怪行为
我正在尝试通过 binding adapter 更改应用字体。
BindingUtils.class
class BindingUtils {
private final val TAG : String = "DataBindingUtils";
companion object {
@JvmStatic
@BindingAdapter("android:customFont")
fun customFont(textView: TextView,font: String){
try {
textView.typeface = Typeface.createFromAsset(textView.context.assets,"fonts/$font")
}catch (e: Exception){
}
}
}
在我使用的 XML 中
android:customFont="@{@string/font}"
字符串具有字体名称
<string name="font">ge_ss_two_light.otf</string>
一切正常,但是当我将更多内容加载到 recyclerview 时,发生了一些错误“字体变粗并再次恢复正常”:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。