Where should I put the "ttf" files in an Android project?

Viewed 37890

I'm trying to use fonts in my project using Typeface. I copied the "font.ttf" into a folder named "fonts" inside "assets" folder. But eclipse do not allow to compile it. It shows an error on fonts folder. What should I do?

The error I get is:

invalid resource directory name     fonts   /NoRats/assets  line 1  Android AAPT Problem
7 Answers

You should put fonts inside this path

\app\src\main\assets\fonts

[Note : Create a new directory(Folder) inside the assests directory in the above patha i have created ]

Then put your ttf font file inside the fonts directory . You can set your font like this way :

Typeface anyName  = Typeface.createFromAsset(Context,"fonts/yourFontFileName.ttf");

simpleTextView.setTypeface(anyName);
Related