How to change the font on the TextView?

前端 未结 16 1078
清歌不尽
清歌不尽 2020-11-22 08:09

How to change the font in a TextView, as default it\'s shown up as Arial? How to change it to Helvetica?

16条回答
  •  失恋的感觉
    2020-11-22 08:30

    First download the .ttf file of the font you need (arial.ttf). Place it in the assets folder. (Inside assets folder create new folder named fonts and place it inside it.) Use the following code to apply the font to your TextView:

    Typeface type = Typeface.createFromAsset(getAssets(),"fonts/arial.ttf"); 
    textView.setTypeface(type);
    

提交回复
热议问题