Android webview: wait with drawing of page until it's completely loaded - android

I'm working on an android app (just a ChromeWebView that connects to a specific website), and it all works fine, except for the fact that you see the page loading just like on your computer.
Is it possible to, if I click a link for example, wait with the redrawing of the page until it's completely loaded and then pops up at once?

First make your layout background color white then make the WebView invisible.
after this use AsyncTask then put your webview loading in doInBackground and when it's finished in onPostExecute make your webview visible.
so the user will see the white layout first then the visible webview after fully loaded in postexcute
you could use onpagefinished instead of AsyncTask like this :
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// your code }
});
sorry if my english not good

Related

Webview within a scroll view loading html wrongly on first load

I have done my research and I haven't found a suitable question for my problem. I got a WebView inside a ScrollView, and once I get the HTML from my service, I call
myWv.loadDataWithBaseURL(null,myHtml,"text/html","utf-8",null);
Nothing special there. The problem I'm having is that, when I run my Application in a 4.4.2 Android tablet, the WebView loads the HTML with the words split in lines, eg:
This
is
my
sentense
And after a second it renders the HTML correctly but the ScrollView's scroll is as big as the number of lines it rendered before loading the HTML correctly. I have tested in 3 different smartphones and everything is fine, only in the tablet it seems to happen, probably due to some performance issue since my HTML is huge.
Does any of you have have had this problem before and knows how to solve it? Thanks in advance.
Extend WebViewClient. And in your custom WebViewClient overload the method onPageFinished.
#Override
public void onPageFinished(WebView view, String url) {
// If you create a listener, here you can trigger it
// you can show the webview here as it will be already measured.
}
If you show the webview when the page is already entirely loaded there won't be any ugly animation.

Intercepting the call to display of dropdown in Webview

While using webview, i can set up a WebChromeClienton it and intercept the alerts(and then customize it also) by overriding
onJsAlert(WebView view, String url, String message,JsResult result)
Is there a way that i can intercept the display of dropdown dialogs( that comes from <select> tags of HTML)? Basically i wanted to customize the view of that dialog? I tried overriding a few functions in WebChromeClient but it didnt work.
<select> elements are handled inside the rendering engine, there are no callbacks provided by WebView for customizing them.
The best you can do is to use JavaScript code in the web page you display. See for example this answer: https://stackoverflow.com/a/23515955/4477684.

Stop WebView rendering until the page is fully-loaded

I'm working on an app that is using WebView. Unfortunately, when user clicks a link, when the page is loading, the whole WebView area "blinks" until its loading is complete. There's also 1 more problem with it - I'm using a JavaScript that reverses colors of the page at the end of its loading - so until it's fully-loaded, the colors are normal, so again - blinking.
So, what I wannna do is "stop" rendering of the WebView, until the page is completely loaded - then, resume the rendering, so it won't blink. How to do that?
Note: I don't want to modify the webpage to achieve what I want. I have to modify WebView behavior.
And one more note, because it's maybe not clear: by "stop rendering" I mean "display currently rendered page continually until the new one is fully loaded" :)
First make your layout background color white then make the WebView invisible.
after this use AsyncTask then put your webview loading in doInBackground and when it's finished in onPostExecute make your webview visible.
so the user will see the white layout first then the visible webview after fully loaded in postexcute
sorry if my english not good
You could implement a custom WebView, and override it's invalidate() method to do nothing until the page is fully loaded.

Android webview sometimes not loading images

I have a simple Activity to show a webview and a back button. Here is the code that I use to load the URL that I want in the webview.
The webpage that I am loading in on a server online, it has a few form elements plus a few links that when clicked I need to keep loading them inside the webview.
Now the problem is very often the page loads without the images, I can see the form elements though or only blank white page. I am testing this on wifi so internet is working fine.
Why is it not loading images and how can I make sure it does? I even tried making all images in the html page have absolute paths, but that did not help.
Later Edit: I found out what was causing this. Maybe others will run into this. I had this in the manifest file android:hardwareAccelerated="true". After removing it the content inside all the webviews is loading smoothly.
Second later edit: It is terrible, I get the initial page load now, but forms are not submitting and after some going back and forward to the webview, new images do not load anymore. Is it a memory problem? How do I make it start fresh every time?
WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient());
wv.loadUrl(filepath);

JQTouch android webView configuration

I'm developing an application which is mainly a webview and will display a JQTouch UI. Two of the 3 views work just fine, however, I have a view which loads another page with a form which does not work at all. This view loads up just fine but when I click the link to go to the form the link just stays highlighted and nothing happens. I have overriden all of the methods in webviewclient and webchromeclient and placed breakpoints within with no luck. None of the hooks catch when I click the links.
The part that truly confounds me is that it works in the phones browser but not in my webview. Is there a setting on webview that I may be missing which would make it act like the phones browser?
Any help or suggestions would be appreciated.
The fix for this was to override onLoadResource as the link was being treated as a resource and not a new page load. I tried calling webView.loadUrl right in the override of loadREsource but that caused an endless loop so I had to write some logic to load the url properly into my webView. This seems a bit hacked but it works.

Categories

Resources