2012-08-07 78 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

相关问题