I'm trying to recreate this airbnb carousel using ...
# compose
c
I'm trying to recreate this airbnb carousel using Accompanist Pager. My code works/looks pretty much perfectly BUT the pager doesn't have padding on the left side (like the image shows)
Copy code
HorizontalPager(
    state = pagerState,
    horizontalAlignment = Alignment.Start,
    modifier = Modifier.fillMaxWidth(),
    itemSpacing = 16.dp) { page ->
    Column(modifier = Modifier.fillMaxWidth(0.85f)) { content[page]() }
}
^ Looks great, but no padding off the left side
If I add
padding(start = 16.dp)
to the HP modifier then I DO get the padding on the left side BUT when scrolling, all of the items get clipped when paging to the next item.
c
You want to use
contentPadding
to add some inner padding
c
Oh jeez. I was looking at these args and didnt see content padding.
Oh wait. That doesn't exist at all? I guess I'm using the wrong thing or applying the padding in the wrong spot?
c
Ah, there is no
contentPadding
🤦‍♂️. Would you mind raising an issue and I'll add it tomorrow?
c
Woot. I want going crazy!
c
Ha, I could have sworn that I added that functionality!
c
Less than an hour from asking a question, there is a change made to support this. 🤯 @cb THE GOAT Thank you!
c
It's not fully working yet 😬. Its a tricker issue than I initially thought.
c
Doesn't matter. Still great. hahaha Appreciate it. In the meantime let me know if there's some sort of workaround I could/should use. But I can also wait a bit for this to come through.
@cb it's alive! Hooray. Thank you so much for your hard work on this one. Question about my original question though. In your opinion, how should one create that "airbnb" carousel. I have cards that are all match parent width. When I put them into a horizontal view pager: 1. Should I change their width to a hard coded width 2. For the initial padding off of the left, I should use content padding? 3. For the spacers between every item, should I do that on the composable itself?
🙌 1