5

I have custom WebView class in which default zoomIn/zoomOut controls are disabled and I'm manually handling the zoom events.

Also I have WebViewClient in which onScaleChanged() handler is overriden, it looks like this:

mWebViewClient = new WebViewClient(){
    @Override
    public void onScaleChanged(WebView view, float oldScale, float newScale) {
        super.onScaleChanged(view, oldScale, newScale);
        System.out.println("Scale changed");
    }
};

The problem happens when zoomIn()/zoomOut() is called than onScaleChanged() handler is executed multiple times, I'm getting "Scale changed" multiple times. This event should be called only once per zoomIn()/zoomOut() event.

Also worth to mention is that this problem happens only on devices having Android version below 4.4. On Android 4.4 the handler is called only once per zoom event (as it should be). I got this problem on Android 4.3.1, Android 4.1.1 and as well on Android 4.0.4 (all of the devices were mobile phones).

As we all know that from Android 4.4 Chromium powered WebViews are introduced and I'm guessing that with this update this problem was solved but I can't manage to find anything related on the Web.

Why this handler is called multiple times on WebView powered by WebKit engine and on Chromium powered WebViews it works as expected?

pedo5000
  • 61
  • 5
  • try this response http://stackoverflow.com/questions/9696118/why-does-onlayout-and-onsizechanged-get-called-twice-on-an-orientation-change – bogdand Jan 21 '14 at 15:34

0 Answers0