2012-08-07 73 views
3

是否可以一次性爲整個android應用程序設置自定義字體。我的意思是我不想在每個活動中爲每個文本視圖使用setTypeFace。不僅僅是文字瀏覽,還有每一個可能的文字。在android應用程序中設置自定義字體

+4

使自定義字體集自定義的TextView,並使用該TextView的,而不是默認的TextView – rajpara 2012-08-07 09:27:28

回答

9

只是讓你自己的TextView:

public class CustomFontTextView extends TextView { 

// make every constructor call init(); 

    private void init() { 
    setTypeFace(...); 
    } 

} 

在XML:

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
    <com.yourcompany.yourproject.views.CustomFontTextView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="Test"/> 
</LinearLayout> 
+3

+1我去與此回答。精湛的答案。 – 2012-08-07 09:40:15

+2

不僅文字瀏覽,但一切,說按鈕,網頁佈局等簡而言之,在應用程序 – 2012-08-07 10:01:23

+0

任何解決方案上述評論?我也在這個問題上做了必要的改變。 – 2012-08-07 11:59:53

相關問題