[Docs][Carousel] Add uncontained variant docs

PiperOrigin-RevId: 566796652
This commit is contained in:
rightnao 2023-09-20 00:32:48 +00:00 committed by Dan Nizri
parent bc824b4344
commit 9ee4aba007
2 changed files with 24 additions and 3 deletions

View File

@ -140,7 +140,8 @@ carousels with `match_parent` as the width will have more and more large items
as the screen size grows.
You can use the hero strategy by passing in the strategy to the
CarouselLayoutManager constructor: `CarouselLayoutManager(HeroStrategy())`.
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
HeroCarouselStrategy())`.
With the hero strategy, it is recommended to use the `CarouselSnapHelper` to snap to the nearest item like so:
@ -157,8 +158,8 @@ A fullscreen strategy shows one item at a time that takes up the entire space
of the carousel.
You can use the fullscreen strategy by passing in the strategy to the
CarouselLayoutManager constructor:
`CarouselLayoutManager(FullScreenStrategy())`.
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
FullScreenCarouselStrategy())`.
With the fullscreen strategy, it is recommended to use a vertical orientation
carousel by either setting the orientation on the CarouselLayoutManager with the
@ -175,6 +176,26 @@ val snapHelper = CarouselSnapHelper()
snapHelper.attachToRecyclerView(carouselRecyclerView)
```
## Uncontained strategy
![An uncontained Carousel](assets/carousel/uncontained.png)
An uncontained strategy fits as many items as possible into the carousel without
altering the item size. With the remaining space, it fits one item that is
the smallest it can be to fill the space but still gets cut off in a
way such that there is a visible effect of items getting smaller as it goes out
of the carousel bounds.
You can use the uncontained strategy by passing in the strategy to the
CarouselLayoutManager constructor: `new CarouselLayoutManager(new
UncontainedCarouselStrategy())`.
As the uncontained strategy does not alter item sizes, it is ideal for use cases
where aspect ratios of the items must be maintained. However, this can lead to
aesthetically displeasing layouts when the carousel size is almost perfectly
divisible by the item size, so it is advised to update the item sizes based on
the carousel size.
## Attributes
Note that in order to use these attributes on the RecyclerView, CarouselLayoutManager must be set through the RecyclerView attribute `app:layoutManager`.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB