material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Carousel] Built-in way to set space between carousel items

Open Emplexx opened this issue 1 year ago • 1 comments
trafficstars

Is your feature request related to a problem? Please describe. The documented way of doing this is setting horizontal margins on the MaskableFrameLayout wrapping the carousel item. This however results in an issue where the left and right edges of the carousel (the way the user sees them) will constantly change as you scroll the carousel. For example, if the carousel recycler view has 16dp margins on the left and right, and the individual items have 4dp margins on left and right for 8dp of total space between, then as you scroll the carousel the actual visible space between the edge of the recycler view and the item will go back and forth between 16dp and 20dp (16+4), this issue becomes more obvious if you set larger margins on the item, for example 8dp on both sides.

Setting the margin only on one side of the item doesn't work because then the item will get slightly cut off on the opposite side of recycler view (see image, the right-most item is getting cut off) image

Using the ItemDecoration API for this purpose also results in items getting cut off at the edges, and the decoration itself doesn't seem to play well with the carousel layout manager because the space between is not consistent (see image, left edge is getting cut off and the two spaces are different) image

Describe the solution you'd like An out of the box solution for setting space between items in a carousel that does not produce any of the issues described above

Emplexx avatar Dec 13 '23 20:12 Emplexx

cc @hunterstich @imhappi

dsn5ft avatar Dec 14 '23 16:12 dsn5ft