Android Question Hide Webview Zoom Controls but still have zoom

Discussion in 'Android Questions' started by tsteward, Nov 23, 2018.

Tags:
  1. tsteward

    tsteward Active Member Licensed User

    Is it possible to turn off the + & - zoom buttons on a webview but still have pinch zoom.

    If I turn off zoom in the designer the buttons are gone but can no longer pinch zoom.
    If I leave it on in designer and use the webviewsettings library I have tried
    setDisplayZoomControls does not have any effect.
    setSupportZoom will turn zoom control off completely.

    Again I want zoomability just not the buttons displayed.

    Thanks
    Tony
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim r As Reflector
    r.Target = WebView1
    r.Target = r.RunMethod(
    "getSettings")
    r.RunMethod2(
    "setBuiltInZoomControls"True"java.lang.boolean")
    r.RunMethod2(
    "setDisplayZoomControls"False"java.lang.boolean")
     
    Last edited: Nov 26, 2018
    tsteward likes this.
  3. tsteward

    tsteward Active Member Licensed User

    Thank you Erel,
    After adding your code above I get the following error
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    My mistake. I've updated the code.
     
  5. kisoft

    kisoft Active Member Licensed User

    HI
    I added this code to my project and I get this error.
    Code:
    *** Service (starter) Create ***
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    Cannot get methods of class: com.android.webview.chromium.ContentSettingsAdapter, disabling 
    cache.
    Error occurred on line: 
    36 (Main)
    java.lang.ClassNotFoundException: com.android.webview.chromium.ContentSettingsAdapter
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:
    453)
        at java.lang.Class.forName(Class.java:
    378)
        at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(
    JavaObject.java:342)
        at anywheresoftware.b4j.object.JavaObject.RunMethod(
    JavaObject.java:119)
        at kamil.sc.main._activity_create(main.java:
    403)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:738)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:360)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:260)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at kamil.sc.main.afterFirstLayout(main.java:
    104)
        at kamil.sc.main.access$
    000(main.java:17)
        at kamil.sc.main$WaitForLayout.run(main.java:
    82)
        at android.os.Handler.handleCallback(Handler.java:
    789)
        at android.os.Handler.dispatchMessage(Handler.java:
    98)
        at android.os.Looper.loop(Looper.java:
    164)
        at android.app.ActivityThread.main(ActivityThread.java:
    6710)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:
    240)
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This time it will work...

    Apparently the settings class is a special type of class.
     
  7. kisoft

    kisoft Active Member Licensed User

    Thanks great, it now works.
     
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