在TextView中设置Roboto字体 - xml

Tob*_*sen 17 android textview

我发现关于这个话题的几个职位,但所有这一切的主题或者设置字体与setTypeFace()方法上的TextView对象,或创建该字体设置为自定义类Robotoextends TextView.据我所知,从API级别11(?)或其他东西,我们可以将TypeFace设置为xml属性,一些如何.像这样:

   <TextView
      android:id="@+id/profileHeader"
      android:layout_width="100dp"
      android:layout_height="100dp"
      android:typeface="roboto"
      android:text="Hello, world">
   </TextView>
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?如果应用程序在低于API级别11(?)的设备上运行,是否可以进行回退:

 android:typeface="roboto|monospace|serif"
Run Code Online (Sandbox Code Playgroud)

cnn*_*nnr 6

看一下RobotoTextView项目.适用于Android 1.5,您可以使用XML属性设置字体.它还包括其他视图,如RobotoButton,RobotoCheckbox等.