change Default font for Android App

android, default, fonts, truetype

Solution

You can create custom TextView and reffer it everywhere.

public class TypefacedTextView extends TextView {

    public TypefacedTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontName);
        setTypeface(typeface);
    }
}

Inside view.xml

<packagename.TypefacedTextView
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:text="Hello"/>

Problem

Okay, I know how to change what font is used on individual textboxes in my app, but I want ALL the text in my app to use this custom font and color, and currently the only way I can think of to do his is to reference each box and set them to the proper font and color. while it's doable it seems rather a clunky method, is there a better way?

Original source

Related problems