Skip to content

Commit 9ee4aba

Browse files
imhappidsn5ft
authored andcommittedSep 20, 2023
[Docs][Carousel] Add uncontained variant docs
PiperOrigin-RevId: 566796652
1 parent bc824b4 commit 9ee4aba

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
 

‎docs/components/Carousel.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ carousels with `match_parent` as the width will have more and more large items
140140
as the screen size grows.
141141

142142
You can use the hero strategy by passing in the strategy to the
143-
CarouselLayoutManager constructor: `CarouselLayoutManager(HeroStrategy())`.
143+
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
144+
HeroCarouselStrategy())`.
144145

145146
With the hero strategy, it is recommended to use the `CarouselSnapHelper` to snap to the nearest item like so:
146147

@@ -157,8 +158,8 @@ A fullscreen strategy shows one item at a time that takes up the entire space
157158
of the carousel.
158159

159160
You can use the fullscreen strategy by passing in the strategy to the
160-
CarouselLayoutManager constructor:
161-
`CarouselLayoutManager(FullScreenStrategy())`.
161+
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
162+
FullScreenCarouselStrategy())`.
162163

163164
With the fullscreen strategy, it is recommended to use a vertical orientation
164165
carousel by either setting the orientation on the CarouselLayoutManager with the
@@ -175,6 +176,26 @@ val snapHelper = CarouselSnapHelper()
175176
snapHelper.attachToRecyclerView(carouselRecyclerView)
176177
```
177178

179+
## Uncontained strategy
180+
181+
![An uncontained Carousel](assets/carousel/uncontained.png)
182+
183+
An uncontained strategy fits as many items as possible into the carousel without
184+
altering the item size. With the remaining space, it fits one item that is
185+
the smallest it can be to fill the space but still gets cut off in a
186+
way such that there is a visible effect of items getting smaller as it goes out
187+
of the carousel bounds.
188+
189+
You can use the uncontained strategy by passing in the strategy to the
190+
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
191+
UncontainedCarouselStrategy())`.
192+
193+
As the uncontained strategy does not alter item sizes, it is ideal for use cases
194+
where aspect ratios of the items must be maintained. However, this can lead to
195+
aesthetically displeasing layouts when the carousel size is almost perfectly
196+
divisible by the item size, so it is advised to update the item sizes based on
197+
the carousel size.
198+
178199
## Attributes
179200

180201
Note that in order to use these attributes on the RecyclerView, CarouselLayoutManager must be set through the RecyclerView attribute `app:layoutManager`.
1.26 MB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.