Lucien Guimaraes
10/08/2021, 10:16 AMLucien Guimaraes
10/08/2021, 10:56 AMnitrog42
10/08/2021, 11:15 AMcb
10/08/2021, 12:37 PMcontentPadding = PaddingValues(start = 16.dp, end = 128.dp)
cb
10/08/2021, 12:37 PMnitrog42
10/08/2021, 12:43 PMnitrog42
10/08/2021, 12:47 PMnitrog42
10/08/2021, 12:48 PM@OptIn(ExperimentalPagerApi::class)
@Composable
fun PagerContent() {
HorizontalPager(count = 10, contentPadding = PaddingValues(end = 100.dp)) {
Box(
Modifier
.size(200.dp)
.background(Color(Random.nextInt()))
)
}
}
I'm not sure what is the way to have each square follow each other without any spacenitrog42
10/08/2021, 12:48 PMnitrog42
10/08/2021, 12:49 PMLucien Guimaraes
10/08/2021, 1:36 PMThis is working as intended. If you wish to implement the screenshot from above, you would use something likeAh ok I will check this, thanks! BTW, is there any reason for this change?contentPadding = PaddingValues(start = 16.dp, end = 128.dp)
cb
10/08/2021, 2:49 PMModifier.fillMaxWidth()
on your content (plus maybe aspectRatio(1f)
if you want them to be square).cb
10/08/2021, 2:52 PMLazyRow
forced us to re-think how it works. The new API is more restrictive and focused to what Pagers should be (in terms of UX).
What most people are using Pagers for (including @nitrog42's design above) is closer to a LazyRow
+ snapping, than a Pager.cb
10/08/2021, 2:52 PMnitrog42
10/08/2021, 3:03 PMcb
10/08/2021, 3:04 PMcontentPadding
+ key
are key benefitsnitrog42
10/08/2021, 3:14 PMnitrog42
10/08/2021, 3:14 PM@OptIn(ExperimentalPagerApi::class)
@Composable
fun PagerContent() {
HorizontalPager(
count = 10,
contentPadding = PaddingValues(start = 20.dp, end = 20.dp),
itemSpacing = 16.dp,
verticalAlignment = <http://Alignment.Top|Alignment.Top>,
modifier = Modifier
.fillMaxSize()
.background(Color.Green)
) {
Box(
Modifier
.requiredHeight(100.dp)
.background(Brush.verticalGradient(colors = listOf(Color.Blue, Color.Red)))
.fillMaxWidth()
)
}
}
still center the content :nitrog42
10/08/2021, 3:14 PMnitrog42
10/08/2021, 3:15 PMfillParentMaxSize()
nitrog42
10/08/2021, 3:22 PM