Android Question [solved] set zooming level on webView

Discussion in 'Android Questions' started by Didier9, Apr 12, 2017.

  1. Didier9

    Didier9 Active Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Do While WebView1.Zoom(false) = True
    Loop
     
    GMan and Didier9 like this.
  3. Didier9

    Didier9 Active Member Licensed 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.
     
  4. DonManfred

    DonManfred Expert Licensed User

    Have you tried to call it in the PageLoaded event?
     
    Didier9 likes this.
  5. Didier9

    Didier9 Active Member Licensed User

    Apparently there is no PageLoaded event on this webview...
     
  6. DonManfred

    DonManfred Expert Licensed User

    What Webview are you using then??? You are NOT talking about the B4A Webview?
     
  7. Didier9

    Didier9 Active Member Licensed User

    Yes I am using the B4A webview.
    I setup an event like this:
    Code:
    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
     
  8. Didier9

    Didier9 Active Member Licensed User

  9. Didier9

    Didier9 Active Member Licensed User

    Works perfectly! Thanks!
     
  10. DonManfred

    DonManfred Expert Licensed User

    sorry, that´s what i meant
     
  11. Didier9

    Didier9 Active Member Licensed 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.
     
  12. DonManfred

    DonManfred Expert Licensed User

    Show your appreciation clicking on LIKE on the helpful post ;-) (Note i´m a like-Hunter :D)
     
    aidymp and MarcoRome like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice