Stylianos Gakis
10/14/2021, 1:22 PMStylianos Gakis
10/14/2021, 1:22 PMStylianos Gakis
10/14/2021, 1:26 PMStylianos Gakis
10/14/2021, 1:27 PMval claimStatusDataList: List<ClaimStatusData> = ...
val pagerState = rememberPagerState()
Column {
HorizontalPager(
count = claimStatusDataList.size,
key = { page: Int -> claimStatusDataList[page].id },
state = pagerState,
itemSpacing = 16.dp,
contentPadding = PaddingValues(horizontal = 12.dp),
) { page: Int ->
val claimStatusData = claimStatusDataList[page]
ClaimStatusCard(
claimStatusData = claimStatusData,
)
}
Spacer(Modifier.height(16.dp))
HorizontalPagerIndicator(
pagerState = pagerState,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
}
With ClaimStatusCard
being that card item you’re looking at. Not sure if that composable’s internals are important or not.Stylianos Gakis
10/14/2021, 1:34 PMitemSpacing
contentPadding
be 0.dp, it seems to always work.
When itemSpacing
is 0 and contentPadding
is non-zero, it works just fine too.
When itemSpacing
is non-zero and contentPadding
is 0, it stops working, getting this weird behaviour that doesn’t settle properly in the centre of the item again.Lucien Guimaraes
10/14/2021, 1:46 PMAndrey Kulikov
10/14/2021, 1:50 PMitemSpacing
is incorrectly handled, please file a bug in Accompanist repoStylianos Gakis
10/14/2021, 1:52 PMAndrey Kulikov
10/14/2021, 1:55 PMStylianos Gakis
10/14/2021, 2:02 PMval extraPadding = PaddingValues(
start = if (page == 0) { 0.dp } else { 6.dp },
end = if (page == claimStatusDataList.lastIndex) { 0.dp } else { 6.dp },
)
to “fake” a 12.dp spacing between them.
Your approach should work too, but I want the item to look centred when it’s the one selected, I’m guessing adding only an end padding would make it look a bit off.
I am in the process of writing the bug report now. Is it ok if I add a link to this discussion as well? This isn’t a public channel that’s why I wonder.Andrey Kulikov
10/14/2021, 2:05 PMStylianos Gakis
10/14/2021, 2:16 PM