Scrolling A Textview To A Specific Line
I have a TextView inside a ScrollView. Let's say the ScrollView is named s and the TextView is named t. I have many lines to be displayed in the TextView and at the same time I wan
Solution 1:
Found the answer here.
Instead of calling scrollTo
directly, we must call post
instead on the ScrollView. This works.
t.setText(aVeryLongString);
s.post(new Runnable() {
@Override
publicvoidrun() {
int y = t.getLayout().getLineTop(40); // e.g. I want to scroll to line 40
s.scrollTo(0, y);
}
});
Post a Comment for "Scrolling A Textview To A Specific Line"