mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-05 12:07:44 +08:00
[Docs][Carousel] Add uncontained variant docs
PiperOrigin-RevId: 566796652
This commit is contained in:
parent
bc824b4344
commit
9ee4aba007
@ -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 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`.
|
||||
|
||||
BIN
docs/components/assets/carousel/uncontained.png
Normal file
BIN
docs/components/assets/carousel/uncontained.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Loading…
x
Reference in New Issue
Block a user