Adding a lazy list to our layout
In Chapter 3, Developing the UI with Jetpack Compose, we saw how we can add composables to our Activity
class to be rendered on the screen. Lazy lists are just such composables. In this chapter, we will focus on LazyColumn
, but the same principles apply when using LazyRow
, LazyVerticalGrid
, and LazyHorizontalGrid
composables. To add a LazyColumn
composable to our layout, we need to add the following tag to our containing composable:
LazyColumn (tag -> composable) {
}
The appearance and behavior of a LazyColumn
composable can be altered by passing different arguments to the LazyColumn
composable function. You can explore the source code of LazyColumn
to discover the different options.
You can read more about LazyColumn
and LazyRow
(its horizontal equivalent) here: https://packt.link/Qd2Zi.
It is hard to think of a scenario where we would not want our lazy list to be scrollable, since its main value is in its ability...