在android应用程序中设置自定义字体

在android应用程序中设置自定义字体,android,custom-font,Android,Custom Font,是否可以一次性为整个android应用程序设置自定义字体。我的意思是我不想在每个活动中的每个文本视图中使用setTypeFace。不仅是文本视图,还有所有可能的文本 只需创建自己的文本视图: public class CustomFontTextView extends TextView { // make every constructor call init(); private void init() { setTypeFace(...); } } 在xml中: &l

是否可以一次性为整个android应用程序设置自定义字体。我的意思是我不想在每个活动中的每个文本视图中使用
setTypeFace
。不仅是文本视图,还有所有可能的文本

只需创建自己的文本视图:

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>


使用自定义字体设置自定义文本视图,并使用该文本视图而不是默认文本视图,不仅是文本视图,还包括所有内容,如按钮、网页布局等。简言之,以上评论的appany解决方案中的所有文本?我对这个问题也做了必要的修改。从应用程序的任何地方都无法修改。根据您的回答,可能需要扩展
视图
类,然后扩展应用程序中使用的每个视图类型