I have a clocktopia
font on my android device and it's only on some applications.
How do I use that particular font programmatically?
Thank you.
I have a clocktopia
font on my android device and it's only on some applications.
How do I use that particular font programmatically?
Thank you.
First, put the .ttf (or other font file) in your /assets directory. Then, set the font face of your textview with the following code.
TextView textView = (TextView) findViewById(R.id.myTextView);
Typeface font = Typeface.createFromFile("path-to-file");
textView.setTypeface(font);
Unfortunately you cannot use custom typefaces in XML (so you also cannot define a custom theme with your font).
Custom fonts and XML layouts (Android)
You can use the TextViewPlus class provider here to load the typeface from xml but I don't know of a way to use a theme to do this automatically.