Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Compose: Difference between LazyColumn and Column with verticalScroll

I tried to look for reasons to use LazyColumn vs Column with verticalScroll. What is the difference between them? Like why would one be an ideal choice compare to other. They both make screen scrollable, isn't it? Would choosing one over the other one be wrong in any case?

like image 301
oop Avatar asked Dec 16 '25 13:12

oop


1 Answers

LazyColumn is RecyclerView counterpart of Compose while Column with verticalScroll is ScrollView counterpart.

Any Composable inside Column with vertical scroll enters composition the moment Column is composed while LazyColumn uses SubcomposeLayout to subcompose Composables on screen and one extra when you reach last visible item on Screen.

Also LazyColumn offers some features where Column doesn't

flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior()

let's so you easily implement flingBehavior especially with 1.3.0-beta02 snap behavior can implemented with rememberSnapFlingBehavior()

Also rememberLazyListState() provides information about first item index, offset and layoutInfo and visible items which enables more customization than rememberScrollState() like this color and scale animation using visible item positions.

like image 54
Thracian Avatar answered Dec 19 '25 06:12

Thracian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!