【发布时间】:2015-05-21 02:42:23
【问题描述】:
大家好,在我的应用程序中,我正在使用 webview,在这个 webview 中,我想以编程方式设置字体类型。目前在我的资产文件夹中,我有 Roboto-Bold.ttf、Roboto-Light.ttf、..... 和其他一些文件。目前我将其设置为:
text = "<html><head>"
+ "<style type=\"text/css\">body{color: #000; text-align: justify; background-color: #fff;font-family: file:///android_asset/fonts/Roboto-Medium;}"
+ "</style></head>"
+ "<body>"
+ sb.toString()
+ "</body></html>";
但我认为它不起作用,因为它生成与 for 相同的输出:
text = "<html><head>"
+ "<style type=\"text/css\">body{color: #000; text-align: justify; background-color: #fff;font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;}"
+ "</style></head>"
+ "<body>"
+ sb.toString()
+ "</body></html>";
这里我使用的是 font-familyas: font-family: \"Helvetica Neue 但仍然会产生相同的输出。
然后我如何设置我的资产/字体文件夹中存在的字体类型 Roboto-Light.ttf。
任何建议将不胜感激。提前致谢
【问题讨论】:
-
您是否尝试过将字体设置为视图而不是文本?
标签: android fonts android-fonts