Android:字体错误:不允许的类型。

发布于 2025-01-06 18:28:26 字数 860 浏览 2 评论 0原文

我正在创建一个样式 xml 文档,但遇到了问题。我想使用 droid serif 字体,但无法在模拟器中使用它,只能在 Eclipse 的预览屏幕中使用。有时我可以编写 2 而不会出现错误,但是当我尝试在 Android 模拟器中运行该程序时,出现错误:错误:错误:不允许整数类型(在'android:typeface'处,值为'2')。当我按ctrl+space查看我可以写什么时节目(除其他外) serif,但是当我写serif时,它说单词“serif”不正确拼写。

这是 .xml 文件中的部分:

<style name="Header">
  <item name="android:layout_width">wrap_content</item>
  <item name="android:layout_height">wrap_content</item>
  <item name="android:textColor">#444444</item>
  <item name="android:paddingBottom">15dp</item>
  <item name="android:gravity">center</item>
  <item name="android:typeface">serif</item>
</style>

I am creating a style xml document, and I've ran into a problem. I want to use the droid serif font, but I can't use it in an emulator, only in the preview screen in Eclipse. Sometimes I can write <Item name="android:typeface">2</item> without getting an error, but when I try to run the program in the Android Emulator, I get an error: error: Error: Integer types not allowed (at 'android:typeface' with value '2'). When i press ctrl+space to see what I can write it shows (among others) serif, however when i write <Item name="android:typeface">serif</item> it says The word 'serif' is not correctly spelled..

Here's the part from the .xml file:

<style name="Header">
  <item name="android:layout_width">wrap_content</item>
  <item name="android:layout_height">wrap_content</item>
  <item name="android:textColor">#444444</item>
  <item name="android:paddingBottom">15dp</item>
  <item name="android:gravity">center</item>
  <item name="android:typeface">serif</item>
</style>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽蝶幻影 2025-01-13 18:28:26

Eclipse 有一个针对 XML 中字符串值的拼写检查器...如果拼写检查器无法识别单词,通常您会得到“拼写不正确”的信息。如果确实如此,它仍然应该编译并工作。也许这就是这里发生的事情?

Eclipse has a spell checker for string values in XML...usually you get the "not correctly spelled" thing if it is a word that the spell checker does not recognize. It should still compile and work though, if this is actually the case. Maybe that's what's going on here?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文