On occasion links in the WebView will not respond. The highlight press color will appear around them but nothing happens. I am also using WebViewClient's shouldOverrideUrlLoading and that function is not called when this happens.
Edit:
I have narrowed this issue down to the following circumstances:
- The webpage is the first page a WebView opens.
- The webpage uses meta name="viewport" attribute in the html head
- The WebView is using WebView.getSettings().setUseWideViewPort(true);
- Android 2.1 (Doesn't appear to happen in later versions, didn't test earlier)
If a webpage meeting those above is opened no links will work. If another similar page is loaded, those links will not work either. It is not until you load a page without meta name="viewport" that links start to work. After a page without that meta attribute is opened and then you load a page with the meta viewport attribute, the links start working.
This seems like a ridiculous work around but I guess it works. The first time the WebView loads, if you load a blank dummy html file like
before you load anything else, it appears to fix the problem. It also looks like the dummy file has to load completely first, not just start loading.
Just a follow up on this problem : The op solution did not work for me. But I had
setLongClickable
set tofalse
on theWebView
and it completely stopped theWebView
to respond to touch events but only onAndroid 2.1
.Removing the line :
made the
WebView
responsive and working as expected again.