You can disable the vertical scroll bar before appending new text to the TextView
, and post an event to reenable it after the text has been drawn.
Something like this:
textView.setVerticalScrollBarEnabled(false);
textView.append("New Text");
textView.post(new Runnable() {
@Override
public void run() {
textView.setVerticalScrollBarEnabled(true);
}
});
Of course you should reuse a single Runnable
object for enabling the scroll bar, instead of creating a new one on every change to the text.
Note that if you set the TextView
gravity to bottom, then it will be constantly scrolled to the bottom whenever the text is changed, regardless of any scrolling done by the user in the interim.