【发布时间】:2020-05-27 22:54:18
【问题描述】:
我正在尝试从 MainActivity 中的特定 EditText 更改字体,但出现以下错误:
java.lang.RuntimeException: 未找到字体资源 font/af.ttf
代码:
val texto: EditText = findViewById(R.id.texto)
var face = Typeface.createFromAsset(assets, "font/af.ttf")
texto.typeface = face
我该如何解决这个问题?
【问题讨论】:
-
这不是资产,而是资源。资产位于您的资产文件夹中。这回答了你的问题了吗? create typeface from font resource id