I have a TextView which is filled with 500+ words and I wish to programmatically vertically scroll the contents to a certain phrase. I thought I had this solved using tv.scrollTo(x,y) however despite scrolling to the correct position, I can no longer manually scroll back up past the position. It's as if the previous words are no longer in the view.
int offset = tv.getText().toString().indexOf("the text i wish to scroll to");
tv.scrollTo(0, tv.getLayout().getLineTop(tv.getLayout().getLineForOffset(offset)));
I've also tried with
tv.scrollTo(0, tv.getLayout().getLineTop(tv.getTop() + tv.getLayout().getLineForOffset(offset)));
Note my TexView is not in ScrollView container, so I am not trying to scroll the tv within a scrollview but instead scroll vertically the text within the tv itself. As it would be by a user using their finger.
So what is the correct command / way to scroll a textview to a certain position based on specific text content which still allows the user to manually scroll back to text in the textview prior to the found position?