I would like to use new custom fonts in an android application. please be precise and specific when explaining, i am a newbie. Namely, i would like to let my android application use these new android custom fonts http://developer.android.com/design/style/typography.html. Thank you. please help.
Asked
Active
Viewed 1.3k times
-1
-
7[Duplicate](http://stackoverflow.com/q/3203694/1050058). To who answered, You guys should flag duplicate to encourage newbie search before ask. There are many similar questions on SO. – Trung Nguyen Oct 06 '12 at 04:25
-
http://stackoverflow.com/a/7197867/1436931 – Mohsin Naeem Oct 06 '12 at 04:34
-
This should've been closed as a dupe, not as "not a real question" – Ky - Aug 05 '14 at 20:06
3 Answers
17
We can use custom fonts using this way,
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
txt.setTypeface(font);
Refer this tutorial for Full knowledge.

Aerrow
- 12,086
- 10
- 56
- 90
-
-
i dont think we can do it using xml layout and the easy way to do it is from coding – G_S Oct 06 '12 at 03:41
-
-
@ejobity: Refer this too.. http://stackoverflow.com/questions/2376250/custom-fonts-and-xml-layouts-android – Aerrow Oct 06 '12 at 04:33
5
You simply need to put the fonts .ttf file in your assets folder and assign it to a text field or anything you want to apply it to in your main activity like this:
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
txt.setTypeface(font);
Here's a great tutorial that will teach you all you need to know about this: http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/

Anup Cowkur
- 20,443
- 6
- 51
- 84