【发布时间】:2013-03-31 19:06:38
【问题描述】:
我找到了几篇关于这个主题的帖子,但是所有这些主题要么使用 TextView 对象上的 setTypeFace() 方法设置字体,要么创建一个自定义类将字体设置为 Roboto 和 @987654324 @TextView。据我从 API-Level 11(?) 或其他方面了解,我们能够以某种方式将 TypeFace 设置为 xml 属性。像这样:
<TextView
android:id="@+id/profileHeader"
android:layout_width="100dp"
android:layout_height="100dp"
android:typeface="roboto"
android:text="Hello, world">
</TextView>
这样做的正确方法是什么?如果应用程序在低于 API 级别 11(?) 的设备上运行,是否可以进行回退,例如:
android:typeface="roboto|monospace|serif"
【问题讨论】:
-
我认为除了默认字体之外,没有其他方法可以在 Android TextView 中从 XML 设置字体。