m4tx
m4tx

Reputation: 4511

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" :)

Upvotes: 2

Views: 2035

Answers (2)

corsair992
corsair992

Reputation: 3070

You could implement a custom WebView, and override it's invalidate() method to do nothing until the page is fully loaded.

Upvotes: 0

amorenew
amorenew

Reputation: 10896

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

Upvotes: 0

Related Questions