I have a WebView and I would like my app to find a mark on the text(I'm using the symbol ► in the html).I have lots of html files each with almost 10 of these markings.
I have done it pretty easily with TextView doing this:
int offset=texto.indexOf("SPECIFIC MARKING ON TEXT");
final int line = textview.getLayout().getLineForOffset(offset);
final int y = textview.getLayout().getLineTop(line); // e.g. I want to scroll to line
final ScrollView s = (ScrollView)findViewById(R.id.ScrollView01);
s.post(new Runnable() {
@Override
public void run() {
s.smoothScrollTo(0, y);
}
});
But how do I accomplish that on Webview ? The reason I use Webview is due to better text formatting.
In fact, it's even simpler with a WebView. You can use the findAll method for the first occurrence, then findNext(true) for the following markers. The view will automatically scroll to the requested text.
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