Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 812
John Watson Avatar asked Jun 06 '26 08:06

John Watson


1 Answers

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>
like image 75
Vladimir Ivanov Avatar answered Jun 07 '26 22:06

Vladimir Ivanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!