How to use custom fonts in an android application?

2019-09-20 17:25发布

问题:

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.

回答1:

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.



回答2:

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/



回答3:

try this links here and here

The .ttf files are used to get different format into our android application. Its a easy way to work with .ttf files. The only thing you need to get is get all the available .ttf files by googling