Android Runtime Exception font asset not found

后端 未结 13 886
执念已碎
执念已碎 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

    I have looked into all the answer but none of them worked for me. I found a new solution after reading the documentation. Here are the steps to follow:

    1. Go to file menu
    2. In new, go to Folder and create assets folder
    3. Paste your font file in this assets folder
    4. Use in your code using Typeface attribute.

      Typeface type = Typeface.createFromAsset(getAssets(), "myfont.ttf"); textView.setTypeface(type);

    Now, you are all set to use the fonts you like.

提交回复
热议问题