RunTime异常:无法生成本机字体

时间:2014-06-05 07:24:51

标签: java android fonts runtime

我将开发一个Android项目并且我声明了一个函数,它被设置为项目字体,但是当我在设备上测试ptoject时,我将获得运行时异常。我的函数。请帮助我们

private void configureFonts() {
    Typeface tf = ConfigureFont.configure(MainActivity.this,
            "Roboto-Light.ttf");
    tf = ConfigureFont.configure(MainActivity.this, "Roboto-Thin.ttf");
    etUsername.setTypeface(tf);
    etPassword.setTypeface(tf);
    tf = ConfigureFont.configure(MainActivity.this, "Roboto-Bold.ttf");
    btnLogin.setTypeface(tf);
}


public class ConfigureFont {
public static Typeface configure (Context context, String fontName) {
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/" + fontName);
    return tf;
}

}

0 个答案:

没有答案