tags:

views:

143

answers:

2

Hi All,

I applied custom font to an 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(mTypeface);

So anyone can plz get me out of this issue?

Thanks..

+1  A: 

I've successfully used this before. The only difference between our implementations is that I wasn't using a subfolder in assets. Not sure if that will change anything, though.

benvd
A: 

benvd is right. Don't use a fonts subdirectory.

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 in the assets folder not int he res folder. And 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 but myFont.ttf

Octavian Damiean
I also tried without using subdirectory, but it shows no effect...
RATTLESNAKE
Edited my response with the solution now.
Octavian Damiean
Could u please send me some working demo project? I have tried both in assets/fonts/xyz.ttf and assets/xyz.ttf folder but it doesn't take that font. It displays only default font..
RATTLESNAKE
Sure here is the link to the zipped up project. http://dl.dropbox.com/u/8288893/customFont.zip
Octavian Damiean