Android introduces simple use of third-party font libraries

在一个页面中给TextView设置三方的字体

首先,在assets文件夹下建立一个fonts文件夹,然后把字体库导入该文件夹下

var typeFace = Typeface.createFromAsset(mContext.getAssets(),"fonts/sourcehanserifcn_regular.otf")//Apply fonts 
tvtext.setElegantTextHeight(true)//This is indispensable, without adding tvtext, the height will become much larger and it is not beautiful 
tvtext.setTypeface (typeFace)

Just used it, record it

Guess you like

Origin blog.csdn.net/qq_25462179/article/details/124861593