https://kotlinlang.org logo
#compose
Title
# compose
w

wintersoldier

05/02/2022, 8:42 AM
Hi , What is the alternative of ScrollBar in compose. I have already tried Modifier.verticalScroll . Wanted to understand is there a way to acheive scrollview
d

Dragos Rachieru

05/02/2022, 9:05 AM
You use
Modifier.scrollable
that acts like a
ScrollView
or `LazyRow`/`LazyColumn` that acts like a
RecyclerView
w

wintersoldier

05/02/2022, 9:12 AM
I used Column(Modifier.scrollable ) and no ScrollView is getting visible , Basically I need a scrollbar when the scrolling is happening
d

Dragos Rachieru

05/02/2022, 9:28 AM
What about putting the layout in a box like:
Copy code
Box{
  val stateVertical = rememberScrollState(0)
  Something(
    modifier = Modifier
        .fillMaxSize()
        .verticalScroll(stateVertical)
  )
  
  VerticalScrollbar(
    modifier = Modifier.align(Alignment.CenterEnd)
            .fillMaxHeight(),
    adapter = rememberScrollbarAdapter(stateVertical)
  )
}
w

wintersoldier

05/02/2022, 9:29 AM
Checked that already , But VerticalScrollBar is not accesible
d

Dragos Rachieru

05/02/2022, 9:32 AM
yeah, it is not available without
compose-jb
, you can still draw it yourself like this: https://stackoverflow.com/a/68056586/5827505
w

wintersoldier

05/02/2022, 9:35 AM
Tried the same , but the scrollbar is not getting visible. If you already tried and working for you , can you pls share the snippet of the implementation
d

Dragos Rachieru

05/02/2022, 9:37 AM
I haven't used it on android, only on desktop, I will try these days and tell you if it worked.
w

wintersoldier

05/02/2022, 9:46 AM
Sure thanks
40 Views