.svg文件作为HTML中的对象不显示在Android WebVIew中 [英] .svg file as object in HTML not displayed in Android WebVIew
问题描述
我的应用程序具有一个WebView控件,该控件能够加载.svg文件:当url是.svg文件时,它会正确显示.
My app has a WebView control that is able to load .svg files: when the url is a .svg file it is correctly displayed.
我修改了代码,以免直接加载.svg文件,因此我必须调用
I modified the code not to load directly the .svg file so that I have to call something like
webView.loadDataWithBaseURL(baseUrl,"<html><body><object data='cover.svg'></object></body></html>","text/html", "UTF-8","");
-
上述代码适用于图片,但不适用于svg文件.
The above mentioned code works with images but not with svg files.
具有上面提到的HTML参数字符串作为HTML代码的HTML文件已在Firefox(在Linux下)及其svg对象中正确显示.
An HTML file with the HTML parameter string above mentioned as HTML code is correctly displayed in Firefox (under Linux) with its svg object.
对象始终会加载与WebView/浏览器兼容的文件.
The object is always loaded with a WebView/browser-compatible file.
我希望我的代码能够处理可以放置在对象中的每种与WebView/浏览器兼容的文件.
I want my code to be able to handle every kind of WebView/browser-compatible file that can be placed in an object.
我的代码怎么了?
推荐答案
这适用于多种格式:
webView.loadDataWithBaseURL(baseUrl,"<html><body><object onload='event.target.style.minWidth=screen.width;event.target.style.minHeight=screen.height;' data='cover.svg'></object></body></html>","text/html", "UTF-8","");
这篇关于.svg文件作为HTML中的对象不显示在Android WebVIew中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!