我想通过XML弗朗字体资源目录设置字体,但在使用app:fontStyle
,app:fontWeight
和app:font
gadle建立font.xml
文件失败,错误字体在XML使用支持库
/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:
命名空间heppens
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文件中看到任何错误,建议我进行更正。 –
请阅读此行支持库26.0支持运行Android API版本14和更高版本的设备上的XML字体功能。 当您通过支持库在XML布局中声明字体系列时,请使用应用程序名称空间。 注意:从Android支持库26.0开始,您必须声明两组属性以确保在运行Android 8.0(API级别26)或更低的设备上加载字体。 –
我想你是缺少Android支持库26.0 –