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've found a better answer to this issue. It turns out that WebView
does have scrollTo()
, getScrollX()
and getScrollY()
methods as you'd expect. They're a bit hidden in the documentation because they're inherited from View
(via AbsoluteLayout
-> ViewGroup
-> View
). This is obviously a better way to manipulate the WebView
's scroll position than the somewhat cumbersome JavaScript interface.
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