Is it possible to disable all scrolling and zooming in an android webview?

3k Views Asked by At

I tried to find an answer but have thus far failed.

I have an activity that uses a WebView. Everything that is displayed to the user is rendered in HTML and JavaScript. That is, the WebView takes all the screen it can. The APK is used for storing certain persistent data and launching the WebView.

The UI has an icon based navigation menu at bottom (5 icons across the bottom of the screen), and a couple of visual elements across the top (logo image and search button). Everything in between the top elements and bottom navigation bar can be changed, refreshed or updated depending on user actions. The various HTML layouts that are displayed between the top and bottom constants can be swiped left, right, up and down.

The problem: When the user taps the right-most navigation icon in the lower right of the screen, the entire WebView layout shifts left 5-10pixels. If the right-most icon is tapped near its left edge, this does not happen. Tapping another icon will shift the WebView back to its correct alignment. Tapping the left-most icon does not cause a similar behavior to the right. Tapping active or inactive HTML elements (that can be moved by swiping) near either edge of the screen does not result in the shifting behavior.

Initially the area on the right of the screen was filled with white when the WebView shifted, and I thought it was a ScrollBar. I have done every bit of ScrollBar and zoom disabling I can. Now the area is the background color (black) when the shift occurs.

Does anyone know a way to lock the durn WebView in place?

1

There are 1 best solutions below

0
On

Yes, you can disable all the scrolling in Webviews by changing the settings of WebView. Here is the code for that:

WebView myWebView = (WebView) findViewById(R.id.appView); 
myWebView.setVerticalScrollBarEnabled(false);
myWebView.setHorizontalScrollBarEnabled(false);