如何使用Android的工作室自定义字体 [英] How to use custom font in Android Studio
本文介绍了如何使用Android的工作室自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用自定义的字体在Android的工作室,因为我们在Eclipse一样。但遗憾的是无法弄清楚哪里放了资产文件夹!
I was trying to use custom font in Android Studio as we did in Eclipse. But unfortunately could not figure out where to put the 'assets' folder!
推荐答案
下面是几个步骤来解决它:
Here is the few steps to solve it:
- 转到(项目文件夹)
- 和应用程序>来源>主
- 创建文件夹的资产>字体到主要文件夹。
-
把你的'abc.ttf到字体文件夹。
- Go to the (project folder)
- Then app>src>main
- Create folder 'assets>fonts' into the main folder.
Put your 'abc.ttf' into the fonts folder.
AssetManager am = context.getApplicationContext().getAssets();
typeface = Typeface.createFromAsset(am,
String.format(Locale.US, "fonts/%s", "abc.ttf"));
setTypeface(typeface);
或尝试这种方式:
or try this way:
TextView tx = (TextView)findViewById(R.id.textview1);
Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/abc.ttf");
tx.setTypeface(custom_font);
这篇关于如何使用Android的工作室自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文