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!

About these ads
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: