I have a WebView in my application which has HTML content rendered in it and size of HTML content is larger than size of WebView. Due to which content is scrolling inside it when user drags his/her finger on it. I want to stop this INTERNAL scrolling being happening with content.
Heres what I have already tried so far:
WebView view = new WebView(context); //context is of Activity
view.setHorizontalScrollBarEnabled(false);
view.setVerticalScrollBarEnabled(false);
view.setScrollContainer(false);
and in CSS as:
overflow : hidden !important;
Kindly suggest solutions except Disabling Finger Drag (Hack) for webview because that disturb my other functionality, which is as follows:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent.getAction() == MotionEvent.ACTION_MOVE)
{
return true;
}
}
setScrollContainer(false); Don't forget to add the webview. setOnTouchListener(...) code above to disable all scrolling in the webview.
setnestedscrollingenabled set it to false.
To disable vertical scrolling in flutter webview you can override onVertivalDragUpdate() correspondingly.
Add a container to your webview that wraps all your content and sits just below the body
element, like so:
<body id="myBody">
<div class="container">
<!-- All your content goes in this new div.container -->
</div>
</body>
Then, add this CSS to your page:
body {
height: 100%;
width: 100%;
pointer-events: none;
}
div.container {
overflow: hidden!important;
height: 100%;
width: 100%;
}
The problem is that a WebView seems to ignore scrolling on the body
despite overflow rules, and since a body
expands to meet its contents, it'll always think there is more to scroll to. What this is doing is resetting the body to the size of the WebView, and then using the container to keep the body from expanding beyond the WebView with more content.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With