android - 使用支持库的 XML 字体

标签 android xml namespaces

我想通过 XML 字体资源目录设置字体,但在 font.xml文件同时使用 app:fontStyle , app:fontWeightapp: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/

相关文章:

android - Xamarin Forms 中的应用程序设置/属性类似于 Android 中的共享首选项

java - Android:Android Studio 与 Eclipse

r - NAMESPACE 中的 ImportFrom 函数在 document() 上被删除

android - 启动 Desktop main 时出现 libgdx ClassNotFoundException - Mac、IntelliJ

Android fragment 找不到 id 的 View

sql - 使用 SQL Server 上另一个 XML 的节点更新 XML 列

mysql - Perl:使用 LibXML 将 XML 转换为 MySQL

java - 使用 SAX 解析器解析包含元音变音符的 XML 文件

PHP 和 XPath 循环

namespaces - TCL 包和命名空间