Home > Back-end >  Android Studio - Kotlin - how to display scrollable text
Android Studio - Kotlin - how to display scrollable text

Time:04-29

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

CodePudding user response:

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

https://i.stack.imgur.com/OKRGj.png

Subsequently, inside the code, just call the setMovementMethod method of the view

https://i.stack.imgur.com/sITsJ.png

  • Related