开发者

How to force WebView to skip images?

开发者 https://www.devze.com 2023-03-23 06:43 出处:网络
Can someone a开发者_如何学Cdvice me how to tune up Android WebView to skip images from remote server (without image placeholders)Try using :

Can someone a开发者_如何学Cdvice me how to tune up Android WebView to skip images from remote server (without image placeholders)


Try using :

webView.getSettings().setLoadsImagesAutomatically(false);


webView.getSettings().setLoadsImagesAutomatically(false);
webView.getSettings().setBlockNetworkLoads (true);


webView.getSettings().setBlockNetworkImage(true);

and in webview onPageFinished

webView.loadUrl("javascript:(function(){ var imgs=document.getElementsByTagName('img');"+
                         "for(i=0;i<imgs.length;i++) { imgs[i].style.display='none'; } })()");


In onCreate webView.getSettings().setBlockNetworkImage(true);

In onPageFinished of WebViewClient webView.getSettings().setBlockNetworkImage(false);

0

精彩评论

暂无评论...
验证码 换一张
取 消