I’m trying to programmatically scroll a WebView to the location of a particular element in the DOM tree. But so far I haven’t been able to get the WebView to respond to scroll requests. I’ve tried calling JavaScript that uses window.scrollTo(...), but the WebView doesn’t respond. On the Java side, I’ve tried calling the WebView.flingScroll(...) method. WebView will respond to flingScroll, but what I need is a scrollTo(...) capability. Any ideas?
I’m trying to programmatically scroll a WebView to the location of a particular element
Share
I’ve found a better answer to this issue. It turns out that
WebViewdoes havescrollTo(),getScrollX()andgetScrollY()methods as you’d expect. They’re a bit hidden in the documentation because they’re inherited fromView(viaAbsoluteLayout->ViewGroup->View). This is obviously a better way to manipulate theWebView‘s scroll position than the somewhat cumbersome JavaScript interface.