raghunandan
07/18/2022, 11:04 AMHorizontalPager(
count = 10,
contentPadding = PaddingValues(horizontal = 142.dp, vertical = 0.dp),
modifier = modifier
) // 142 is hardcoded value that i came up randomly
val pageOffset = calculateCurrentOffsetForPage(page).absoluteValue
val percentFromCenter = 1.0f - (pageOffset / (5f/2f))
val itemScale = 0.5f + (percentFromCenter * 0.5f).coerceIn(0f, 1f)
val opacity = 0.25f + (percentFromCenter * 0.75f).coerceIn(0f, 1f)
alpha = opacity
scaleY = itemScale
scaleX= itemScale
}.clip(CircleShape)
val contentPadding = (maxWidth - 50.dp) / 2
val center = maxWidth / 2
val offSet = maxWidth / 5
val itemSpacing = offSet - 50.dp
This did the trick. No more hardcoded padding using BoxWithContraints to measure the width.