android - onDraw() not called in WebView -
i need load html webview once put ondraw() method not called if put setwillnotdraw(false) constructor. trying @override dispatchdraw() result same - nothing done.
public mywebview(context context) { super(context); this.setwillnotdraw(false); initialize(context); } private void initialize(context context) { setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); this.html = new myhtml(); this.html.baseurl = ""; try { this.html.loadhtml(context, "htmljh.html"); this.webview = new webview(context); this.webview.getsettings().setallowfileaccess(true); this.webview.getsettings().setjavascriptenabled(true); } catch (ioexception e) { e.printstacktrace(); } webview.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); this.addview(webview); } /**loading html when view attached window**/ @override protected void onattachedtowindow (){ super.onattachedtowindow(); loadbasehtml(); //this method loads needed scripts , define how web view looks (except of size, done onmeasure()) } @override protected void onmeasure (int widthmeasurespec, int heightmeasurespec){ super.onmeasure(widthmeasurespec, heightmeasurespec); system.out.println("measure size..."); float density = getresources().getdisplaymetrics().density; float height = getresources().getdisplaymetrics().heightpixels; this.html.prepareviewwidth(math.round(getwidth()/density), math.round(height/density*2/5)); } @override protected void ondraw(canvas canvas){ super.ondraw(canvas); system.out.println("drawing view..."); this.html.injectjavascripttohtml(); this.webview.loaddatawithbaseurl("file:///android_asset/", this.html.html, "text/html", "utf-8", ""); } i have read questions not calling ondraw() none of them helpful. appreciate help. thank you!
@edit
invalidate() doesn't work too
Comments
Post a Comment