How can I make a TextView automatically scroll as I add more lines of text?

From your Code, two steps have to do:

Step 1

Although you code in Xamarin Android, but as in Java in the xxxActivity.java for terminalOutput invoke must be like this

TextView outputText = (TextView) findViewById(R.id.terminalOutput);
outputText.setMovementMethod(new ScrollingMovementMethod());

Method setMovementMethod() by parameter ScrollingMovementMethod() is the gimmick.

Step 2

And in the layout as in Java-Android also in activity_xxx.xml for the TextView Declaration as above must have to add this

android:gravity="bottom"

When you add new line into the outputText like this:

outputText.append("\n"+"New text line.");

It will scroll to the last line automatically,
and these all the magic for your need.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)