John Watson
John Watson

Reputation: 869

Setting custom font in android application

Is it possible to set a customised font for an entire android application in one shot. I mean I do not want to use setTypeFace for every textview in every activity. And not only textviews but every possible text.

Upvotes: 3

Views: 292

Answers (1)

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43108

Just make your own TextView:

public class CustomFontTextView extends TextView {

// make every constructor call init();

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

}

In 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>

Upvotes: 9

Related Questions