Issue
Is there a way to programmatically scroll to a HTML element that is displayed in a WebView?
The WebView API only provides a scrollTo(x,y)
method, but I can't find a way to determine the position of a displayed element.
Solution
Using Javascript:
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("javascript:document.getElementById('id').scrollIntoView();");
Solution
Maybe not directly with WebView but with javascript. If you have a js function to scroll to an element such as this :
function scrollTo(element){
document.getElementById(element).scrollIntoView();
}
You can call it from WebView with
mWebView.loadUrl("javascript:scrollTo('element')");
Just make sure javascript is enabled in WebView
mWebView.getSettings().setJavaScriptEnabled(true);
Answered By - inmyth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.