How to make Text scrollable in Jetpack Compose

3.7k Views Asked by At

I want to create a scrollable Text in Jetpack Compose.

In View system, we can make text scrollable by using:

android:scrollbars = "vertical" and textview.setMovementMethod(new ScrollingMovementMethod());

Please help me!

I tried using Modifier.verticalScroll(rememberScrollState()) but it doesn't work

1

There are 1 best solutions below

3
On

My Solution might be late for you yet I post it here, it might help others :)

I had the same problem and solved it by wrapping my scrollable Text Component into a LazyColumn. But beware! Your content must be big enough, in my case I had a fixed height, which may result in text overflow

val scroll = rememberScrollState(0)

    LazyColumn( modifier = ...) {
    item {
        Text(
            text = "YourText",
            modifier = Modifier
                .padding(...)
                .height(90.dp)
                .verticalScroll(scroll)
            )
         }
}