Skip to content

Commit

Permalink
[Docs][Carousel] Add uncontained variant docs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 566796652
  • Loading branch information
imhappi authored and dsn5ft committed Sep 20, 2023
1 parent bc824b4 commit 9ee4aba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions docs/components/Carousel.md
Expand Up @@ -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:

Expand All @@ -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
Expand All @@ -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`.
Expand Down
Binary file added docs/components/assets/carousel/uncontained.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9ee4aba

Please sign in to comment.