1

I'm trying to use HorizontalPager (Android compose) but I have a problem. As we can see, the next page touches the first one, I took here a random image with a black background to see better. do you know how i can solve this problem?

enter image description here

HorizontalPager(
        count = 4,
        state = pagerState,
        contentPadding = PaddingValues(end = 82.dp),
        itemSpacing = (-50).dp,
        modifier = Modifier
            .fillMaxWidth()
            .background(color = Color.Transparent)
            .constrainAs(cardCaroussel) { },
    ) { page ->
        Card(
            Modifier
                .background(color = Color.Transparent)
                .graphicsLayer {
                    val pageOffset = calculateCurrentOffsetForPage(page).absoluteValue

                    lerp(
                        start = 0.85f,
                        stop = 1f,
                        fraction = 3f - pageOffset.coerceIn(0f, 1f)
                    ).also { scale ->
                        scaleX = scale
                        scaleY = scale
                    }

                    alpha = lerp(
                        start = 0.5f,
                        stop = 1f,
                        fraction = 1f - pageOffset.coerceIn(0f, 1f)
                    )
                }
                .fillMaxWidth()
                .aspectRatio(1.5f)
        ) {
            Box {
                Image(
                    painter = painterResource(id = R.drawable.cb_nikel),
                    contentDescription = "",
                    modifier = Modifier
                        .fillMaxSize()
                        .background(color = Color.Transparent)
                        .padding(start = 62.dp)
                )
            }
        }
    }
Ali
  • 41
  • 1
  • 4

0 Answers0