Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中使用自定义字体和css_Android - Fatal编程技术网

在android中使用自定义字体和css

在android中使用自定义字体和css,android,Android,我尝试使用css向android应用程序添加一些自定义字体,但字体不变: 我的代码: <style> @font-face { font-family: 'fontname'; src: url('SOMEFONTURL.TTF'); } body { font-family: 'fontname'; color: red; } </style> <style> @font-face { font-family: 'fontname'; src:

我尝试使用css向android应用程序添加一些自定义字体,但字体不变: 我的代码:

<style>
@font-face { 
font-family: 'fontname'; 
src: url('SOMEFONTURL.TTF');
}

body {
font-family: 'fontname';
color: red;
}
</style>
<style>
@font-face { 
font-family: 'fontname'; 
src: url('file:///android_asset/font/font.TTF');
}

body {
font-family: 'fontname';
color: red;
}
</style>

@字体{
字体系列:“fontname”;
src:url('SOMEFONTURL.TTF');
}
身体{
字体系列:“fontname”;
颜色:红色;
}
i、 我确定SOMEFONTURL.TTF存在。 此外,我还尝试读取资产中的字体,但不起作用: 我的代码:

<style>
@font-face { 
font-family: 'fontname'; 
src: url('SOMEFONTURL.TTF');
}

body {
font-family: 'fontname';
color: red;
}
</style>
<style>
@font-face { 
font-family: 'fontname'; 
src: url('file:///android_asset/font/font.TTF');
}

body {
font-family: 'fontname';
color: red;
}
</style>

@字体{
字体系列:“fontname”;
src:url('file:///android_asset/font/font.TTF');
}
身体{
字体系列:“fontname”;
颜色:红色;
}

((安卓4.0.3 API第15级))

那么这是针对网络视图的?如果您在计算机上的普通浏览器中打开HTML,它的样式是否正确?webview是否正确。我在firefox+30和chrome中测试了这段代码,效果非常好。。