android中的自定义字体

Kun*_*ati 3 java android

我试图在textview中使用自定义字体:

tv=(TextView)findViewById(res);
Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/font.ttf"); 
tv.setTypeface(font); 
Run Code Online (Sandbox Code Playgroud)

但是当我运行时,我收到以下错误:

W/System.err(  542): java.lang.RuntimeException: native typeface cannot be made
Run Code Online (Sandbox Code Playgroud)

问题是什么?

NPi*_*ike 11

对我来说,这肯定是我找不到字体文件时收到的消息.简单的事情:

Typeface.createFromAsset(getContext().getAssets(), "fonts/MYFONT.TTF");
Run Code Online (Sandbox Code Playgroud)

当我的字体实际上是font/MYFONT.TTF