Android Question [solved] set zooming level on webView

Didier9

Well-Known Member
Licensed User
Longtime User
The title does not describe my issue very well.
I have a project based on SQLiteLight4.
On my phone (Moto-X 2nd gen) the webview comes up slightly zoomed in (cropping one column out of 5). In order to see the full content width, I have to scroll a little bit to bring the zoom controls and click on '-'.
On other devices I tried (a Moto-G and a couple of tablets), the webview comes up fully zoomed out, which is what I want.
Is there a way (possibly through Javascript) to force the webview to zoom out when loaded?
The webview itself (container) is using the full screen width, it's just the content that does not.
TIA
 

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you Erel, it is working but with a twist...

If I call this immediately after loading the webview, it does not work. Apparently the webview is a separate process and you have to wait until it's done before calling the zoom.

I set a delay (using a timer) to call the zoom function a certain time later after loading the data and that works, at least on this phone and with the small amount of data I am displaying at the moment.
I am concerned that on a slower device, or with a lot more data to display, the delay I set may not be enough. 500 mS seems to work, I tried 300 initially and that was not enough.

It would be nice if there was a way to set a callback so that the zoom would be called when the webview has finished loading.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If I call this immediately after loading the webview, it does not work. Apparently the webview is a separate process and you have to wait until it's done before calling the zoom
Have you tried to call it in the PageLoaded event?
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Yes I am using the B4A webview.
I setup an event like this:
B4X:
Sub WebView1_PageLoaded
    Do While( WebView1.Zoom( False ) = True
    Loop
End Sub
and it never fires (I set a breakpoint in debug mode)
I use B4A version 6.31
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Thanks a lot, you are being very helpful and I appreciate it.
I love B4A, great tool and great support. I can't believe how many answers I got by simply googling through the forum.
 
Upvote 0
Top