Android Typeface createFromAsset

后端 未结 7 2126
滥情空心
滥情空心 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:22

    You can use your View's getContext() method to get the current Context, then use it to get the assets:

    Typeface font = Typeface.createFromAsset(getContext().getAssets(), "robotobold.ttf");
    

提交回复
热议问题