繁体   English   中英

不允许的字符串类型(在“ android:typeface”,值为“ Calibri.ttf”)

[英]String types not allowed (at 'android:typeface' with value 'Calibri.ttf')

如何将自定义字体设置为应用程序字体? 这是我的设置:

  1. 自定义字体位于/assets/fonts/Calibri.TTF
  2. 在清单中,我将应用程序主题设置为: android:theme="@style/AppTheme"
  3. 这是我的style.xml

<resources> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:typeface">Calibri.ttf</item> </style> </resources>

现在,我无法运行该应用程序。 当我尝试编译它时,出现如下错误:

error: Error: String types not allowed (at 'android:typeface' with value 'Calibri.ttf')

字体值应类似于这些值。 “正常,无,serif,等宽”

您需要将您的海关字体从Calibri.ttf重命名为calibri.ttf

其次,您不能直接在资源文件中提供字体

尝试在github上引用它

https://gist.github.com/artem-zinnatullin/7749076

是的,反思。 这个作品看下面的stackoverflow问题是否可以为整个应用程序设置自定义字体?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM