How to use external Fonts in Android


Android provides very few font styles.So in this post I will show how to use external fonts for the TextViews in our android application.

Step1:

Create a folder named 'fonts' in the assets folder of the android application.

Step2:

Download any font in '.ttf' or '.otf'  format and copy it in the fonts folder

Step3:

Create a layout file and add a TextView in the layout and give it an id to be refered.

Step4:

In the onCreate method of the Activity file bind the TextView and set the Typeface as shown below

TextView tvWord = (TextView) findViewById(R.id.tvWord);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/sample.ttf");
tvWord.setTypeface(tf);

Thats it!!! Run the app in an emulator or a device to see the result.