i'am using android WebView
to show xhtml files in my app for display images i am using shouldInterceptRequest
function but when i try to use code below
<svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 1478 2544" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
<image width="1478" height="2544" xlink:href="../Images/Antropoloji_Kapak_on_renk.jpg"></image>
</svg>
shouldInterceptRequest
method not called and image could not shown
iam supporting all versions of android 4+
i can't change the content. I should display exactly what i have given
-edit-
it turns out when i gave size of image smaller than screen it shows it
but still i want to show it even if it is bigger than screen size
I use following html page to display your svg:
<html>
<head>
<title>SVG Test</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" height="100%"
preserveAspectRatio="xMidYMid meet" version="1.1"
viewBox="0 0 3288 2188" width="100%"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image width="3288" height="2188"
xlink:href="file:///android_asset/image.jpg"></image>
</svg>
</body>
</html>
To display embedded image into svg you should use path with file:///android_asset/
prefix. If you want to embed image from another location then assets folder, you also should use file:///
prefix.
Do you mean you can't change response from server?
This case you can wrap <svg>
tag with necessary <html>
and <body>
Try this:
String svgContent = ... // Your code of svg here
String pageContent = "<html><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width'></head><body>" + svgContent + "</body></html>";
webview.loadData(pageContent, "text/html", "utf-8");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.