简体   繁体   English

JetPack Compose 同时滚动多个 LazyColumn

[英]JetPack Compose Scroll together multiple LazyColumn simultaneously

I want multiple All LazyColumn scroll simultaneously我想要多个 All LazyColumn 同时滚动

I can't use LazyHorizontalGrid or LazyVerticalGrid because of inner layout what two layout is different.由于内部布局,我不能使用 LazyHorizontalGrid 或 LazyVerticalGrid,这两种布局是不同的。 How can i share scrolling in multiple LazyColumn?我如何在多个 LazyColumn 中共享滚动?

@Composable
fun TableScreen2(list: List<Time>, cal: Calendar, df: DateFormat) {

    LazyRow(Modifier.fillMaxSize()) {
        item {
            LazyColumn(
                modifier = Modifier
                    .fillParentMaxHeight()
            ) {
                items(count = list.first().timeList.size / 2) {
                    Column(
                        modifier = Modifier
                            .width(60.dp)
                            .height(50.dp),
                        verticalArrangement = Arrangement.Top
                    ) {

                        Text(df.format(stateCal.time))
                        stateCal.add(Calendar.MINUTE, 30)

                    }
                }
            }
        }

        items(4) { listIndex ->
            LazyColumn(modifier = Modifier.fillParentMaxHeight()) {
                itemsIndexed(list[listIndex].timeList) { timeIndex, timeItem ->
                    Box(
                        modifier = Modifier
                            .height(30.dp)
                            .width(60.dp)
                            .background(Color.Gray),
                        contentAlignment = Alignment.Center
                    ) {
                        Text(text = "$timeIndex")
                    }
                }

            }
        }
    }
}

here is gif这是gif

I think you may need to use a LazyVerticalGrid in this case.我认为在这种情况下您可能需要使用LazyVerticalGrid See the documentation here .请参阅 此处的文档

A single LazyColumn, where each entry in the lazy column is a row of 5 items looks like it would fit what you want.单个 LazyColumn,其中惰性列中的每个条目是一行 5 个项目,看起来它适合您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM