Skip to content

hi!i want ask your question about your reply in stackoverflow.com #20

Description

@yuqingweng

how-to-put-a-lazyverticalgrid-inside-a-scrollable-column when item count = 500, maybe have some problems in scroll

@Preview(showBackground = true)
@Composable

private fun Test() {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState())
    ) {
        Box(modifier = Modifier
            .fillMaxWidth()
            .height(200.dp)
            .background(Color.Red))

        Stats(
            modifier = Modifier.heightIn(max = 1000.dp),
            stats = List(500) { it }
        )

        Box(modifier = Modifier
            .fillMaxWidth()
            .height(200.dp)
            .background(Color.Yellow))

    }
}
@Composable
fun Stats(
    modifier: Modifier = Modifier,
    stats: List<Int>
) {
    LazyVerticalGrid(
        modifier = modifier,
        columns = GridCells.Fixed(2)
    ) {

        itemsIndexed(stats) { index, item ->
            Box(
                modifier = Modifier.aspectRatio(1f),
                contentAlignment = Alignment.Center
            ) {
                Text("Item $index")
            }
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions