scrolling vertically to a specific text part in a webview
-
13-10-2019 - |
Question
I'm looking for a way to scroll a webview that a specific part of the contained text is shown.
Scrolling programmatically needs always an integer value of how far to scroll. Is there any possibility of retrieving the y-position of a specific text in that webview?
Solution
If you are the editor of the html content, you could simply use anchors inside the html :
The text I want to scroll to
and then simply use webview.loadurl("mywebpage.html#firstpart")
OTHER TIPS
WebView has the findAll(String)
and findNext()
methods. They're not well documented though, and they seem to have some issues pre-froyo.
This thread in particular may help you give it a try, though. These find methods call native code, so it's not something you could easily override, I don't think. There might be something you could do with Javascript, but that's certainly not something I'm familiar with.