赞
踩
// 加载系统内置字体
val typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD_ITALIC)
// 获取TextView对象
val textView = findViewById<TextView>(R.id.my_text_view)
// 设置字体样式
textView.setTypeface(typeface)
// 加载自定义字体
val typeface = Typeface.createFromAsset(assets, "my_font.ttf")
// 获取TextView对象
val textView = findViewById<TextView>(R.id.my_text_view)
// 设置字体样式
textView.setTypeface(typeface)
下载.ttf文件后置于assets文件夹中即可使用。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。