当前位置: 代码迷 >> Android >> Android 平添设置自定义字体
  详细解决方案

Android 平添设置自定义字体

热度:14   发布时间:2016-05-01 20:07:21.0
Android 添加设置自定义字体

把字体文件放到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")为字体文件路径。
  相关解决方案