Wednesday, April 17, 2013

[android help] Android - Using Custom Font

Android - Using Custom Font - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















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?





























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 it must go in the assets folder not the res folder. So



assets/fonts



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


























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.






















when i have been wrote this code to set my font it dosn't work when i'm start my application suddenly my application is stop..




















default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...