+ 3
Custom fonts in Android app
Do anyone know how to add custom fonts in your Android project?
6 odpowiedzi
+ 4
import android.graphics.Typeface
or learn more about typeface
https://developer.android.com/reference/android/graphics/Typeface.html
+ 6
abc.ttf is the font file
Go to the (project folder)
Then app>src>main
Create folder 'assets>fonts' into the main folder.
Put your 'abc.ttf' into the fonts folder.
AssetManager am = context.getApplicationContext().getAssets(); typeface = Typeface.createFromAsset(am, String.format(Locale.US, "fonts/%s", "abc.ttf")); setTypeface(typeface);
or try this way:
TextView tx = (TextView)findViewById(R.id.textview1); Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/abc.ttf"); tx.setTypeface(custom_font);
+ 4
thanks @Mr Programmer , can you please give me a demo source code, I wanted to make an app with Copperplate script fonts. A demo might be self explanatory.
+ 2
I used that if you say I can post the code but my app crashes Everytime...... don't know what's wrong.... tried alternative methods but all in vain......
+ 2
I tried this, gives an error on line:
"typeface = Typeface.createFrom......"
what are the requirements of this code? I mean like android.support.blablabla...
+ 1
there is a class *TypeFace* . u should store ur font type face file (.ttf file) in *raw/assets* folder.
then u can access it and apply to textviews.
google on "typeface android", ull come to know