Android Code Snippet [B4X] Use WebView to show large images

Discussion in 'Code Snippets' started by Erel, Feb 20, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Tested on B4i And B4A.

    Depends on: XUI / iXUI and JavaObject.
    Code:
    Private Sub ShowImage(Dir As String, FileName As String)
       
    #if B4A
        
    Dim jo As JavaObject = Me
       jo.RunMethod(
    "zoom"Array(WebView1))
       
    #End If
       WebView1.LoadHtml(
    $"<img src="${xui.FileUri(Dir, FileName)}"/>"$'xui is a global XUI object.
    End Sub

    #if Java
    public static void zoom(android.webkit.WebView wv) {
       wv.getSettings().setUseWideViewPort(true);
       wv.setInitialScale(1);
    }
    #End If
    The inline java is required to start zoomed out.
     
    DonManfred, Beja, Laurent95 and 9 others 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