我想通过 XML 字体资源目录设置字体,但在 font.xml
文件同时使用 app:fontStyle
, app:fontWeight
和 app:font
gadle 构建失败并出现错误
/media/shankar/Work Drive/temp/BrainColors/app/src/main/res/font/fonts.xml
Error:attribute 'com.color.brain.braincolors:font' not found Error:attribute 'com.color.brain.braincolors:fontStyle' not found Error:attribute 'com.color.brain.braincolors:fontWeight' not found
Error:/media/shankar/Work Drive/temp/BrainColors/app/src/main/res/font/fonts.xml:0 attribute 'com.color.brain.braincolors:font' not found Error:/media/shankar/Work Drive/temp/BrainColors/app/src/main/res/font/fonts.xml:0 attribute 'com.color.brain.braincolors:fontWeight' not found Error:java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed: Error:com.android.builder.internal.aapt.AaptException: AAPT2 link failed: Error:Execution failed for task ':app:processDebugResources'. Failed to execute aapt
我不明白为什么在使用
app:
时会出现这种情况命名空间fonts.xml
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<font android:fontStyle="normal" android:fontWeight="400" android:font="@font/junegull"
app:fontStyle="normal" app:fontWeight="400" app:font="@font/junegull"/>
</font-family>
最佳答案
您可以查看本教程如何在 xml 中使用字体
fonts-in-xml
我认为您缺少 android 支持库 26.0
关于android - 使用支持库的 XML 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46483415/