更改android字体不起作用 [英] Changing the android typeface doesn't work

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

问题描述

我正在使用以下代码行来更改 android中的字体类型:



<$ p $字体font = Typeface.createFromAsset(this.getAssets(),fonts / Abumohammed.ttf);
textView.setTypeface(font);

我相信 Abumohammed.ttf 是在资产/字体文件夹..但是字体不会改变,不会对textview有任何影响!!

解决方案

Android不支持每个字体文件。当它失败时,它倾向于默默地失败,反而显示默认的字体。我不知道什么Android不喜欢他们中的一些。



我会找到一些肯定有效的字体,比如这个,然后尝试确保剩下的代码好的。如果确实你确定字体文件不起作用,AFAIK你别无选择,只能找到其他的字体。

I am using the following line of code to change the font type in android application :L

Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Abumohammed.ttf"); 
textView.setTypeface(font);

I am sure that Abumohammed.ttf is in assets/fonts folder .. but the font don't change and don't has any effect on the textview !!

解决方案

Android does not support every font file. When it fails, it tends to fail silently, showing the default font instead. I have no idea what Android does not like about some of them.

I would find some font that definitely works, such as this one, and try it to make sure that the rest of your code is OK. If indeed you determine that the font file does not work, AFAIK you have no choice but to find some other font.

这篇关于更改android字体不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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