簡體   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