In my android webview I am able to scrolling outside of web content. I want to disable that. Is that possible? Same applies and for all sides and bottom. I want to scroll my page of course but I want to disable only this scrolling distances.
Asked
Active
Viewed 137 times
0
-
I do not Anjali answer there, and duplicate answers did not work – IntoTheDeep Nov 20 '15 at 10:41
1 Answers
1
Following code will help you to fit the content of Webview with the view:
private void setupWebView() {
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
webView.loadUrl("javascript:MyApp.resize(document.body.getBoundingClientRect().height)");
super.onPageFinished(view, url);
}
});
webView.addJavascriptInterface(this, "MyApp");
}
@JavascriptInterface
public void resize(final float height) {
MyActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
webView.setLayoutParams(new LinearLayout.LayoutParams(getResources().getDisplayMetrics().widthPixels, (int) (height * getResources().getDisplayMetrics().density)));
}
});
}

Anjali
- 1
- 1
- 13
- 20
-
This is my code. WebView and img view. Image view removed after web view fully loads. Can you suggest me what should I change?? [Plunker](http://plnkr.co/edit/Hq71f3?p=info) – IntoTheDeep Nov 20 '15 at 10:25
-