Home > Android, Eclipse, Resources > Setting the font in your Android application

Setting the font in your Android application

To set the font that you want to use in your Android application programmatically, you have to package your font (i.e. “Calibri.TTF”) with your application. Under MySmugProject/resources, create another folder named: “fonts”. Effectively, it should look like – “/MySmugProject/resources/fonts/Calibri.TTF”.

Now in your code append the following:

Typeface calibri = Typeface.createFromAsset(getAssets(), “fonts/Calibri.ttf”);

TextView fname = new TextView(this);
fname.setText(“Dennis”);
fname.setTypeface(calibri);

And we’re done!

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment