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?
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"/>
Put Your different font files in assets folder...
TextView mytextView=(TextView)findViewById(R.id.txtbx);
Typeface fonttype=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf");
mytextView.setTypeface(fonttype);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With