Changing font in android app crashes the application - native typeface cannot be made

醉酒当歌 提交于 2019-12-04 19:52:39

Are you created a folder called fonts in assets or directly placed in assets folder??if folder not created create a folder and place your font file there I think that is the mistake..In your example he is not created any fonts folder he is directly accessing but you are accessing from fonts folder..

If not fonts folder then change this line to.

Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.TTF");

like this..

Typeface font = Typeface.createFromAsset(getAssets(), "amal.TTF");
Gal Rom

i got the same exception. in my case i gave a wrong path to my ttf file. i wrote: /font/somefont.ttf i fixed it by removing the first hyphen: font/somefont.ttf

You'll save yourself a lot of trouble, if you're using Android Studio, by placing the "assets/" folder WITHIN "src/main", NOT on the same level as "src/".

Mario

In Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.TTF"); change to

Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.ttf"); that solved for me.

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