Android Typeface createFromAsset

后端 未结 7 2137
滥情空心
滥情空心 2020-12-14 14:49

I Have a Custom View which draws text onto the Canvas. I want to change the font to a font stored in the assets folder.

I

7条回答
  •  遥遥无期
    2020-12-14 15:20

    First of all, you have to keep your assets folder inside your project and not inside src/main.. And then, create a folder called fonts inside assets. then, put the specific font typeface ttf files inside it.You can use the font typeface in coding like:

    Typeface type = Typeface.createFromAsset(getAssets(),"fonts/filename.ttf");
    textview.setTypeface(type);
    

提交回复
热议问题