如何在webview中设置自定义字体
来源:互联网 发布:易语言打开网页源码 编辑:程序博客网 时间:2024/04/29 01:10
In your assets/fonts folder, place the desired OTF or TTF font (here MyFont.otf)- Create a HTML file that you'll use for the WebView's content, inside the assets folder (here insideassets/demo/my_page.html):<html>
<head>
<style type="text/css">
@font-face {
font-family: MyFont;
src: url("file:///android_asset/fonts/MyFont.otf")
}
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> - Load the HTML into the WebView from code:webview.loadUrl("file:///android_asset/demo/my_page.html");
Take note that injecting the HTML through loadData() has not worked for me. I'd be curious to hear if anybody can get that working.
需要注意的是,这种方式,只能使用.otf格式的字体文件,不能使用ttf格式的。
0 0
- 如何在webview中设置自定义字体
- 如何在iPhone中使用自定义字体
- 如何在工程中使用自定义字体
- 如何在iOS应用中使用自定义字体
- 如何在oracle中设置自定义编辑器
- 如何在报表中设置字体的颜色
- 在Outlook 2007中如何设置新邮件的默认字体?
- 如何在EclipsePHP Studio中设置字体的大小
- 在eclipse中如何设置字体的大小
- 如何在MathType中设置字体默认颜色
- myeclipse中如何设置字体
- 【Android】如何在自定义View中设置自定义的属性
- 如何改变博客自定义模块字体设置
- 在eclipse中设置字体
- c# WinForm中如何在代码中设置控件的padding 设置Label的字体
- c# WinForm中如何在代码中设置控件的padding 设置Label的字体
- QT中如何在ComboBox中设置存放自定义类型
- webview 中textarea设置斜体字体失效的解决方法
- 结对编程初体验
- C# form 传参数的几个方法
- 开始了,少年!
- UVA 题目10285 - Longest Run on a Snowboard(DP+记忆化搜索)
- 数据结构之选择排序c实现
- 如何在webview中设置自定义字体
- 回车和换行
- Slider滑竿+动画
- 二叉搜索树与双向链表
- IntelliJ IDEA的高效快捷键设置
- 第一行代码笔记5(ListView)
- Apache—DBUtils框架简介、DbUtils类、QueryRunner类 、ResultSetHandler接口
- 表情代码
- Linux内核编程初探:块设备驱动程序——Ramdisk