We are going to develop an android application for show a autocad drawing file in svg format in which ecma script is using. We have tested the application in emulator and opened the svg file in webview. our problem is that ecmascript in XML tags are not executed in webview in android. We know that android is supporting SVG from 3.0 only. Does it not support ecmascript in svg?
Thanks in advance
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 Shibu
The . svg image uploads correctly and displays correctly as a logo on desktop in any browser. The logo . svg does not display on android or iphone in any browser.
If you want to use some icons that are not present in the list of predefined icons, then you can add your own icon by selecting the Asset Type as Local File(SVG, PSD) and then select the path of your file by clicking on Path. After that click on Next > Finish. Now your icon will be added to your res/drawable folder.
An SVG (scalable vector graphics) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999. You can even manipulate SVG files with code or your text editor.
Android (3.0 and later) supports SVG with 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.
There are 5 ways how to add svg in the html:
<img>
tag<embed>
tag<iframe>
tag <object>
tag<svg>
tag)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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With