Android Runtime Exception font asset not found

后端 未结 13 893
执念已碎
执念已碎 2021-01-04 01:11

Here is my code and screenshot I\'m trying to set custom font typeface but Runtime exception occurs font asset not found while font file is in asset folder. Am I missing som

13条回答
  •  余生分开走
    2021-01-04 01:54

    If you use AndroidAnnotations, in app build.gradle, verify if assets folder is ok: ex: main/src/assets.

    If you change de font, uninstall your app from your device/emulator, and run again.

    Code:

    public static void setFontFace(Context context, TextView textView) {
      Typeface type = Typeface.createFromAsset(context.getAssets(), "myfont.ttf");
      textView.setTypeface(type);
    }
    

提交回复
热议问题