问题描述
我们将开发一个Android应用程序用于显示一个AutoCAD的绘制在ECMA脚本使用SVG格式文件。我们有在测试模拟器中的应用,打开web视图中的SVG文件。我们的问题是,ECMAScript中的XML标签没有在web视图执行在机器人。我们知道Android从3.0只支持SVG。是否它不支持的ECMAScript在SVG?
We are going to develop an android application for show a autocaddrawing file in svg format in which ecma script is using. We havetested the application in emulator and opened the svg file in webview.our problem is that ecmascript in XML tags are not executed in webviewin android. We know that android is supporting SVG from 3.0 only. Doesit not support ecmascript in svg?
在此先感谢
final String mimeType = "text/html";
final String encoding = "utf-8";
final String html = "<p><img height=\"600px\" width=\"600px \"src=\"file:///android_asset/drawing3.svg\" /></p>";
WebView wv = (WebView) findViewById(R.id.webview_component);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, "");
Ragards石埠
RagardsShibu
推荐答案
的Android(3.0及更高版本)支持SVG与ECMAScript的。
Android (3.0 and later) supports SVG with ECMAScript.
问题是,不执行ecmacript在SVG时,SVG在&LT增加; IMG&GT;
标记。我还测试了几种桌面浏览器,当SVG是&LT; IMG&GT;
标签,ECMAScript中没有任何人执行
The problem is that ecmacript in svg isn't executed when svg is added in the <img>
tag. I also tested it in several desktop browsers and when svg is in <img>
tag, ecmascript wasn't executed in any of them.
有5种方法如何添加SVG在HTML:
There are 5 ways how to add svg in the html:
- 添加它作为与图像的
&LT; IMG&GT;
标记 - 在与嵌入的
&LT;嵌入&GT;
标记 - 在与嵌入的
&LT; IFRAME&GT;
标记 - 在与嵌入的
&LT;对象&gt;
标记 - 在嵌入SVG code直接到HTML(使用
&LT; SVG&GT;
标签)
- Add it as an image with the
<img>
tag - Embed it with the
<embed>
tag - Embed it with the
<iframe>
tag - Embed it with the
<object>
tag - Embed svg code directly into the html (using
<svg>
tag)
在SVG ECMAScript的只执行,如果SVG嵌入&LT;嵌入&GT;
,&LT; IFRAME&GT;
或&LT;对象&gt;
标记。当直接在embeding SVG code &LT; SVG&GT;
标签,可能需要做一些code的变化(例如,在HTML的其他地方移动的脚本)的,但它也应该工作。
The ecmascript in the svg is executed only if the svg is embedded in <embed>
, <iframe>
or <object>
tag. When embeding svg code directly in <svg>
tag, it might be necessary to do some code changes (e.g. moving the scripts elsewhere in the html), but it should also work.
这篇关于在Android的SVG支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!