Reputation: 955
I have an app that shows a full screen svg image in a WebView. Everything works perfectly fine in my Android 4.2 test device and in the emulator. However in Android 4.4 the svg image just shows up as a broken image.
Does anyone have a fix for this problem or know why it is happening? Thanks.
browser=(ClickableWebView)view.findViewById(R.id.my_browser);
browser.setWebViewClient(new WebViewClient());
browser.getSettings().setBuiltInZoomControls(true);
browser.getSettings().setRenderPriority(RenderPriority.HIGH);
browser.getSettings().setDisplayZoomControls(false);
browser.getSettings().setLoadWithOverviewMode(true);
browser.getSettings().setJavaScriptEnabled(true);
url = "<html><body style=\"margin: 0; padding: 0 \"><table align=\"center\" cellpadding=0 cellspacing=0 style=\"height:100%; width:100%; \"><tr><td align=\"center\" style=\"vertical-align:middle;\"><img src=\"file:///android_res/drawable/" + filename + ".svg\" height=\"" + height + "\"/><br><font size=\"0\">.</font></td></tr></table></body></html>";
browser.loadDataWithBaseURL(url, url, "text/html", Encoding.UTF_8.toString(), url);
Upvotes: 0
Views: 1599
Reputation: 955
Okay so after some playing around i've managed to fix it.
For some reason on Android 4.4, svg images must be stored in the assets folder (file:///android_asset/). On previous Android versions it was fine to store svgs in the drawable folders but it seems this is not the case anymore.
Upvotes: 1