I want to apply some font say Times New Roman to only my application. Not to the whole system and not to specific view. As far I know
to apply font to specific view we store font file in asset folder and get into the application as follow.
1] Typeface mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
textView.setTypeface(mFace);
2] To apply font to whole application I can replace the DroidSans.ttf file with my font file.
I can use first way to apply font to my application but It won't be a good solution because I need to modify everywhere and I don't want to do that if there is any better way is available.
In the Action Launcher Settings menu, tap the “Appearance” option. Scroll down within the “Appearance” menu and then tap “Font.” Choose one of the custom Action Launcher fonts available within the “Font” menu. Tap on one of the options to confirm your choice and then select the back button to return to your app drawer.
I made a custom textview widget and in the constructors made a call to this code:
public static void SetCustomFont (TextView t, String fontName, Context c) {
Typeface tf = Typeface.createFromAsset(c.getAssets(),
fontName);
t.setTypeface(tf);
}
I'm using the same font over the whole application so I put the fontName in the constuctor and then did a global Find/Replace for TextView
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