WebView Pictures Click to view

Source: Internet
Author: User

Requirements: WebView in the picture click on the complete screen view

 This. Setwebviewclient (Newwebviewclient () {@Override Public Booleanshouldoverrideurlloading (WebView view, String URL) {LOGHELP.D ("Lyg", "shouldoverrideurlloading:" +URL); if(! Textutils.isempty (URL) && isautourl () && (Url.startswith ("http.//") | |URL. StartsWith ("xuehu://")) {urlbus.dourl (URL,"", GetContext (), Customwebview. This, isopennewactivity); return true; } Else {                    return Super. shouldoverrideurlloading (view, URL); }} @Override Public voidonpagefinished (WebView view, String URL) {Super. onpagefinished (view, URL); Eventbus.getdefault (). Post (Newwebviewcloseevent ());                Mlists.clear ();            Addimagelistener (); } @Override Public voidOnreceivedsslerror (WebView view, Sslerrorhandler handler, sslerror error) {Super. Onreceivedsslerror (view, handler, error);            Handler.proceed (); }        });
//---------webview Picture Click to start------------------    Private voidAddimagelistener () {//in some case, SRC of an IMG tag might is Base64 string but no a URL//we can get image URL by data-src if existsLoadurl ("javascript: (function () {" + "var objs = document.getElementsByTagName (\" img\ ");" + "for (Var i=0;i<objs.length;i++)" + "{" + "if (Objs[i].getattributenode (\" Oncli Ck\ "). specified) continue;                "+" Window.imageListener.addImage (OBJS[I].SRC, OBJS[I].DATASET.SRC); + "objs[i].onclick=function ()"+"{"+"window.imagelistener.openimage(th  IS.SRC, THIS.DATASET.SRC); "                + "     }  "                + " } "                + " })()"); }

By rewriting JS to achieve

WebView Pictures Click to view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.