Android的 - 使用自定义字体 [英] Android - Using Custom Font

查看:112
本文介绍了Android的 - 使用自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我申请自定义字体到的TextView ,但它似乎并不改变字体。

I applied a custom font to a TextView, but it doesn't seems to change the typeface.

下面是我的code:

    Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
    TextView myTextView = (TextView)findViewById(R.id.myTextView);
    myTextView.setTypeface(myTypeface);

任何人都可以,请让我离开这个问题?

Can anyone please get me out of this issue?

推荐答案

在Mobiletuts +上有文本格式为Android非常好的教程。 快速提示:定制的Andr​​oid字体

On Mobiletuts+ there is very good tutorial on Text formatting for Android. Quick Tip: Customize Android Fonts

编辑:现在测试它自己。这里是解决方案。您可以使用一个子文件夹名为字体,但它必须在资产文件夹不是 RES 文件夹。因此,

Tested it myself now. Here is the solution. You can use a subfolder called fonts but it must go in the assets folder not the res folder. So

资产/字体

另外,还要确保结束我的意思是字体的结局字体文件本身都是小写。换句话说,它不应该是 myFont.TTF ,但 myFont.ttf

Also make sure that the font ending I mean the ending of the font file itself is all lower case. In other words it should not be myFont.TTF but myFont.ttf

这篇关于Android的 - 使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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