Android(安卓)添加设置自定义字体
16lz
2021-01-24
把字体文件放到Asset/font目录下
Typeface typeFace = Typeface.createFromAsset(mContext.getAssets(), "font/fzktjt.ttf");TextView.setTypeface(typeFace);
如果是设置网页的字体,使用WebView渲染,则需要修改网页代码
例如
<html><head><style type="text/css">@font-face { font-family: MyFont; src: url("file:///android_asset/font/fzktjt.ttf")}body { font-family: MyFont; font-size: medium; text-align: justify;}</style></head><body>Your text can go here! Your text can go here! Your text can go here!</body></html其中 src: url("file:///android_asset/font/fzktjt.ttf")为字体文件路径。
更多相关文章
- android-项目结构详解
- Android中wifi的HAL层
- android usb流程
- Android使用其他资源
- android framework service开发原理,以震动模块为例进行讲解
- 在Android(安卓)中使用FFmpeg命令
- Android(安卓)6.0 默认桌面壁纸修改
- Android应用程序组件Content Provider应用实例(4)
- android 手机虚拟按键 震动过程的追溯(1)