views:

213

answers:

3

Hi,

I need to use certain font for my entire application. I have .ttf file for the same. Is it possible to set this as default font, at application start up and then use it elsewhere in the application? When set, how do i use it in my layout XMLs?

Sample code, tutorial that can help me here is appreciated.

Thanks.

+1  A: 

This should help :http://www.androidguys.com/2008/08/18/fun-with-fonts/

Ravi Vyas
Which is to say: no, you can't set a font for the entire application.
CommonsWare
Thanks Ravi and Mark
Samuh
A: 

Yes it is surely possible to do set style to an application in Android. This can achieved using the concept of themes which is explained nicely at http://developer.android.com/guide/topics/ui/themes.html

the100rabh
A: 

Yes, its possible to set the font to the entire application.

The easiest way to accomplish this is to package the desired font(s) with your application.

To do this, simply create an assets/ folder in the project root, and put your fonts (in TrueType, or TTF, form) in the assets.

You might, for example, create assets/fonts/ and put your TTF files in there.

**public class FontSampler extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); TextView tv=(TextView)findViewById(R.id.custom);

Typeface face=Typeface.createFromAsset(getAssets(), "fonts/HandmadeTypewriter.ttf"); tv.setTypeface(face); } }**

Selvakumar