How to use custom fonts in an android application? [closed]

邮差的信 提交于 2019-12-25 18:58:29

问题


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



来源:https://stackoverflow.com/questions/12756464/how-to-use-custom-fonts-in-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!