在使用android添加可下载字体后(基于https://stackoverflow.com/a/47793223),Im无法以编程方式加载添加的字体。
ResourcesCompat.getFont(context, R.font.roboto)结果出现以下错误
android.content.res.Resources$NotFoundException: Font resource ID #0x7f080009
at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:218)
at android.support.v4.content.res.ResourcesCompat.getFont(ResourcesCompat.java:196)但是,一旦我在一些布局文件中指定了相同的字体,比如
android:fontFamily="@font/roboto"它起作用了。
它现在也开始以编程方式工作。
发布于 2018-06-16 17:17:50
https://stackoverflow.com/questions/50889952
复制相似问题