如何添加外部字体为Android应用程序 [英] How to add external fonts to android application

查看:125
本文介绍了如何添加外部字体为Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一些时髦的字体,我的Andr​​oid应用程序。但问题是怎样才能让我的Andr​​oid应用程序支持的外部字体。

I was looking for some stylish fonts for my android application. but the problem is how can i make my android application supportable for external fonts.

感谢你。

推荐答案

您需要创建字体下的资产文件夹中的项目文件夹,并把你的TTF进去。然后在你的活动的onCreate()

You need to create fonts folder under assets folder in your project and put your TTF into it. Then in your Activity onCreate()

TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/mytruetypefont.ttf");
myTextView.setTypeface(typeFace);

请注意,并非所有的TTF会工作。当我尝试,它的工作只是一个子集(在Windows上他的名字写在小盘股的)。

Please note that not all TTF will work. While I was experimenting, it worked just for a subset (on Windows the ones whose name is written in small caps).

这篇关于如何添加外部字体为Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆