Sometimes the stock fonts on Android may not cut it when trying to create the look and feel of your app so embedding a custom typeface file will be the way to go.
First, you may need some cool fonts so I recommend you to check http://www.dafont.com and get some free fonts for you project (read the license agreement before using it in your phone).
Once you have picked your fonts you need to copy it in the assets folder in your application; I normally create a subfolder called fonts but it is not required.
TextView text = (TextView)findViewById(R.id.labelTitle);
Typeface customFont = Typeface.createFromAsset(getAssets(),"font/custom.ttf");
text.setTypeface(customFont);
In the sample above I am setting the "labelTitle" TextView to use my custom.ttf files
Yes, that’s all.
No comments:
Post a Comment