'Android Studio - Kotlin - how to display scrollable text
I am new to Android Studio and Kotlin.
I am outputting texts regularly to the display. Think of an old-fashioned ticker-tape newsfeed, where the latest text is always at the top...
I want to update some field (e.g. TextView) on the display. However, I want: (a) the latest text to appear at the top, and (b) as the number of texts will increase over time, I want the user to be able to scroll down to old texts if they want.
I thought a Scroll View would work for this but I haven't been able to get anything to work as described above.
Can anyone suggest a solution?
Thanks
Garrett
Solution 1:[1]
When a control such as a TextView contains more text than the visible one, you can make the view scrollable simply by setting the following two properties for it in the xml file relating to the layout
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
Subsequently, inside the code, just call the setMovementMethod method of the view
yourTextView.setMovementMethod(new ScrollingMovementMethod())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
