2015-05-29 93 views

回答

0

-Hello 按本Stackoverflow answer

- android:typeface在XML用于改变字体。

- 你最终的代码如下: -

<Textview .......... =android:typeface="normal/sans/monospace"..../> 
0

首先download你需要(ARIAL.TTF)的字体.TTF文件。将它放在资产文件夹(Inside assest文件夹中创建一个名为“fonts”的新文件夹,并将其放在里面)。如果“txtyour”是要应用的字体textvies,使用下面的一段代码,

Typeface type = Typeface.createFromAsset(getAssets(),"fonts/arial.ttf"); 
txtview.setTypeface(type); 
0

如果要更改整个应用程序的字体,然后我会建议使用此样式。

只是将下面的行添加到您的styles.xml文件 -

<style name="AppTheme" parent="AppBaseTheme"> 
    <item name="android:textViewStyle">@style/TextAppearance.Sans</item> 
    <item name="android:buttonStyle">@style/TextAppearance.Sans</item> 
</style> 

<style name="TextAppearance.Sans" parent="TextAppearance.AppCompat.Large"> 
     <item name="android:fontFamily">sans-serif-light</item> 
     <item name="android:textStyle">normal</item> 
</style> 

如果你不想通过更改字体出来的应用程序,然后而不是AppTheme设定的只是简单的定义样式元素每个TextView中要更改字体 -

<TextView 
    style="@style/TextAppearance.Sans" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 
相关问题