WebView Zoom snaps back

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I am using a WebView to display a third-party webpage. When I zoom in or out (either with a pinch or with the .Zoom(True/False) function), The zoom level of the webpage "snaps back" to fit the width of the page to the device.

Displaying the same webpage in the standard Android browser or Opera browser, I can zoom in or out and it behaves as expected.

Any idea why the WebView is snapping back to fill the page with to the device when I tried to zoom? This occurs on both by test devices, a 2.3 phone and a 3.1 tablet.

Thanks,
Barry.
 
Last edited:

canalrun

Well-Known Member
Licensed User
Longtime User
Does it only behave this way on this specific page?

Thanks for the reply.

I have attached a small test app which illustrates the problem I'm seeing.

When I click on the "Calvin" button, the webpage opens. When I try to zoom in (Pinch zoom) at first it zooms but then quickly reverts to adjusting the zoom to fit the page width and re-centering the page. I repeatedly try to zoom in. Each time it readjusts the zoom amount size to fit the page width, until max zoom is reached internally, then it no longer accepts my pinch zooms. I get the same results if I use the .Zoom methods or the +/- buttons on the WebView.

Zooming out, if I try to zoom to less than the page width it re-adjusts the zoom to the page size.

The "Money" page is similar. It will zoom in, but it seems to make an adjustment centering the display after I complete the pinch zoom action. For this page it is more noticeable when zooming out.

There seems to be some processing done by the WebView after the pinch zoom action is complete – re-centering the page and/or adjusting the zoom.

Displaying the same two pages, both the default Android browser and the Opera browser don't perform this centering or correction after the zoom action is complete. They both perform zooming actions as expected.

Any ideas? Is there some setting I need to turn off? Is there another way to display webpages within an application besides the WebView?


Added Later …

I did some Googling for this problem. There turns out to be quite a few people who are experiencing the same thing. Unfortunately, no concrete solutions were mentioned. It was interesting that many of the Google posts had to do with IOS, Safari, and Apple. Is it true that Android borrows the Safari browser from IOS?

Can anyone think of a way to work around this problem? The browser window has to be contained within my app. Opening a default browser with an intent won't suffice. In Windows you can open an Explorer Window making it part of your application. Can something similar to this be done within B4A and Android?

Thanks,
Barry.
 

Attachments

  • wvtest.zip
    6.7 KB · Views: 217
Last edited:
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
You cannot embed another application in your own app. It probably happens because of the pages CSS or JavaScript. I haven't tried it with these pages however it also behaves like this on some pages with the default browser.

Thanks again.

Rather than using the WebView.LoadURL I tried using HTTPUtils2 and a GET of the webpage URL. I pass the returned string to WebView.LoadHTTP. This works correctly. I can zoom as expected without the page "snapping back".

My guess is that there is something being received in the headers that the WebView is responding to.

Barry.
 
Upvote 0
Top