tsteward Well-Known Member Licensed User Longtime User Nov 23, 2018 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Nov 25, 2018 #2 Code: Copy 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 Upvote 0
Code: Copy 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")
tsteward Well-Known Member Licensed User Longtime User Nov 25, 2018 #3 Thank you Erel, After adding your code above I get the following error java.lang.RuntimeException: Method: setBuiltInZoomControls not found in: android.webkit.WebView Click to expand... Upvote 0
Thank you Erel, After adding your code above I get the following error java.lang.RuntimeException: Method: setBuiltInZoomControls not found in: android.webkit.WebView Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Nov 26, 2018 #4 My mistake. I've updated the code. Upvote 0
kisoft Well-Known Member Licensed User Longtime User Nov 26, 2018 #5 HI I added this code to my project and I get this error. Code: Copy *** 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) Upvote 0
HI I added this code to my project and I get this error. Code: Copy *** 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)
Erel B4X founder Staff member Licensed User Longtime User Nov 26, 2018 #6 This time it will work... Apparently the settings class is a special type of class. Upvote 0
kisoft Well-Known Member Licensed User Longtime User Nov 26, 2018 #7 Thanks great, it now works. Upvote 0
BlueVision Well-Known Member Licensed User Longtime User Oct 17, 2021 #8 Really sorry for reopening this, but posting somewhere else rises the fragmentation of valueable information in this case. It belongs directly to this topic... Have some problems with this. I am using multiple webviews within my program, looks to me that the code above only works on a single webview within the application. It fails if I use this code multiple times on different webviews (adressed with a different reflector). The code only affects the last webview adressed... Would be really nice to get this fixed, because the zoom controls in my case hiding to much information, this is really annoying... Any ideas? Until now I did not tried to use the code again directly before accessing the affected webviews. Maybe this is the workaround? Cheers BV Upvote 0
Really sorry for reopening this, but posting somewhere else rises the fragmentation of valueable information in this case. It belongs directly to this topic... Have some problems with this. I am using multiple webviews within my program, looks to me that the code above only works on a single webview within the application. It fails if I use this code multiple times on different webviews (adressed with a different reflector). The code only affects the last webview adressed... Would be really nice to get this fixed, because the zoom controls in my case hiding to much information, this is really annoying... Any ideas? Until now I did not tried to use the code again directly before accessing the affected webviews. Maybe this is the workaround? Cheers BV
BlueVision Well-Known Member Licensed User Longtime User Oct 17, 2021 #9 Fixed in the following way (there is always a simple solution...) When creating layouts with the designer, simply remove the hook for zoomcontrol for the webview affected. Controlling it by code in the way above does not work. Upvote 0
Fixed in the following way (there is always a simple solution...) When creating layouts with the designer, simply remove the hook for zoomcontrol for the webview affected. Controlling it by code in the way above does not work.