Thread
#compose
    t

    Tin Tran

    1 year ago
    I have a question about
    HorizontalPager
    . If each page have difference height then the
    HorizontalPager
    will match the size of the largest page is that correct?
    I have this example
    @ExperimentalPagerApi
    @Preview
    @Composable
    fun test() {
        val pageList = listOf(1, 10, 4)
        Column(
            Modifier
                .fillMaxSize()
                .verticalScroll(rememberScrollState())
        ) {
            Box(
                modifier = Modifier
                    .height(200.dp)
                    .fillMaxWidth()
                    .background(Color.Green)
            )
            HorizontalPager(state = rememberPagerState(pageCount = 3)) { page ->
                Column {
                    repeat(pageList[page]) {
                        Box(
                            modifier = Modifier
                                .height(50.dp)
                                .fillMaxWidth()
                                .background(Color.Red)
                        )
                        Spacer(modifier = Modifier.height(20.dp))
                    }
                }
            }
            Box(
                modifier = Modifier
                    .height(50.dp)
                    .fillMaxWidth()
                    .background(Color.Yellow)
            )
        }
    }
    How do i make the the red boxes go to top and the column not scrolling if the current page can fit into the screen?