2015-05-29 100 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"/> 
相關問題