Created
December 13, 2020 21:49
-
-
Save florinmuscalu/9b424c9b1f3f53f71087ef4ca92aecb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String s = ""; | |
int counter = 1; | |
public void addLine(View view) { | |
TextView tv = findViewById(R.id.test_text); | |
s = s + "Line " + counter + "<br>"; | |
counter++; | |
tv.setText(Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY)); | |
int scrollAmount = tv.getLayout().getLineTop(tv.getLineCount()) - tv.getHeight(); | |
if (scrollAmount > 0) | |
tv.scrollTo(0, scrollAmount); | |
else | |
tv.scrollTo(0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment