I applied a custom font to a
TextView, but it doesn't seems to change the typeface.
Here is my code:
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf"); TextView myTextView = (TextView)findViewById(R.id.myTextView); myTextView.setTypeface(myTypeface);
Can anyone please get me out of this issue?
On Mobiletuts+ there is very good tutorial on Text formatting for Android. Quick Tip: Customize Android Fonts
EDIT: Tested it myself now. Here is the solution. You can use a subfolder called fonts but it must go in the
assets folder not the
res folder. So
Also make sure that the font ending I mean the ending of the font file itself is all lower case. In other words it should not be
myfont.ttf this way must be in lower case
After trying most of the solutions described in this thread, I accidentally found Calligraphy (https://github.com/chrisjenx/Calligraphy) - a library by Christopher Jenkins that lets you easily add custom fonts to your app. The advantages of his lib comparing to approaches suggested here are: