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

tylerwilson

11/30/2020, 5:32 PM
I am starting to prototype a UI in Compose, and wonder if anybody has a sample or knows how to do something like so: something like a calendar, with a scrollable column of background cells (background), and with overlapping blocks of various sizes that scroll along with those cells. In SwiftUI I got it working with a scrollview inside a scrollview. Wonder if something similar is possible in Compose?? Thanks.
m

manueldidonna

11/30/2020, 5:38 PM
In Compose there are LazyColumn/Row and ScrollableColumn/Row and you can nest them
t

tylerwilson

11/30/2020, 5:43 PM
Cool thanks. It was actually easier than I expected:
Copy code
ScrollableColumn(Modifier.fillMaxSize()) {
            Box {
                Column {
                    for (index in 1..30) {
                        Text(
                            "Time $index",
                            modifier = Modifier
                                .height(32.dp)
                                .fillMaxWidth()
                                .background(if (index % 2 == 0) Color.Yellow else Color.Orange)
                        )
                    }
                }
                Text("Block X",
                    modifier = Modifier
                        .offset(x = 64.dp, y = 64.dp)
                        .size(width = 128.dp, height = 64.dp)
                        .background(Color.Blue)
                )
            }
        }
a

allan.conda

11/30/2020, 5:44 PM
There is a complex calendar composable example in one of the compose-samples. You could check that out
👍 1
t

tylerwilson

11/30/2020, 5:44 PM
That is just the first pass. I am not worried about lazy, since i wont have more than 64 ‘cells’.
@allan.conda I see the Calendar component in the crane sample, which is more a date picker. Good example, but not quite what I was looking for. Though I will no doubt be referring to it in the future. Thank you.
🆗 1
3 Views