SVG animation does not work in Android WebView

I have an animated svg page in html, it works fine on a desktop browser, but is static in webview. This is how I initialize webView

webview = (WebView) findViewById(R.id.webView1);
        WebSettings Websettings = webview.getSettings();
        Websettings.setBuiltInZoomControls(true);
        Websettings.setSupportZoom(true);
        Websettings.setJavaScriptEnabled(true);
        Websettings.setBuiltInZoomControls(true);
        Websettings.setRenderPriority(RenderPriority.HIGH);
        webview.getSettings().setPluginState(PluginState.ON);
        webview.setWebChromeClient(new WebChromeClient());
        final MyJavaScriptInterface myJavaScriptInterface = new MyJavaScriptInterface(
                this);
        webview.addJavascriptInterface(myJavaScriptInterface, "activity");
        webview.setVerticalScrollBarEnabled(false);
        webview.loadUrl("file:///android_asset/svgDemo_index.html");
    }

and here is the html code

<body>

<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">

    <rect x="10" y="10" height="110" width="110"
         style="stroke:#ff0000; fill: #0000ff">

        <animateTransform
            attributeName="transform"
            begin="0s"
            dur="20s"
            type="rotate"
            from="0 60 60"
            to="360 60 60"
            repeatCount="indefinite" 
        />
    </rect>

</svg>

</body>

I am testing it on Android 4.1

+4
source share

Source: https://habr.com/ru/post/1542312/


All Articles