All available configuration options for CardStackLayoutManager.
Choose whether cards overlap each other (StackLayout.Overlay, default) or are arranged sequentially like a vertical/horizontal RecyclerView (StackLayout.Linear). In Linear mode, translationInterval becomes the spacing between cards.
manager.setStackLayout(StackLayout.Overlay) // Default
manager.setStackLayout(StackLayout.Linear) // Sequential arrangementExample for Linear:
manager.setStackLayout(StackLayout.Linear)
manager.setStackFrom(StackFrom.Bottom) // Cards rise from bottom
manager.setTranslationInterval(12f) // Spacing in dp between items
manager.setScaleInterval(1.0f) // Optional: keep card sizes identicalChoose between classic Stack (CardStackStyle.Stack, default) and Carousel Style (CardStackStyle.Carousel).
For a carousel-inspired effect:
val carousel = CarouselSetting(
orientation = CarouselOrientation.Horizontal,
scaleMultiplier = 0.18f,
minScale = 0.65f,
tiltAngle = 8f
)
manager.setStackStyle(CardStackStyle.Carousel)
manager.setCarouselSetting(carousel)
manager.setStackFrom(StackFrom.Bottom)
manager.setTranslationInterval(16f)Determines from which side the cards are stacked.
| Value | Description |
|---|---|
StackFrom.None |
Default - no offset |
StackFrom.Top |
From top |
StackFrom.Bottom |
From bottom |
StackFrom.Left |
From left |
StackFrom.Right |
From right |
StackFrom.TopAndLeft |
From top and left |
StackFrom.TopAndRight |
From top and right |
StackFrom.BottomAndLeft |
From bottom and left |
StackFrom.BottomAndRight |
From bottom and right |
manager.setStackFrom(StackFrom.None)Number of visible cards in the stack.
| Default | Value | Description |
|---|---|---|
| ✅ | 3 |
Default - 3 cards visible |
2 |
2 cards visible | |
4 |
4 cards visible |
manager.setVisibleCount(3)Spacing between cards in dp. In Linear mode, this is the actual spacing, in Overlay mode it's the offset.
| Default | Value | Description |
|---|---|---|
4dp |
Tight spacing | |
| ✅ | 8dp |
Default |
12dp |
Wide spacing |
manager.setTranslationInterval(8.0f)Scaling factor for cards in the stack (0.0f - 1.0f). 1.0f means no scaling.
| Default | Value | Description |
|---|---|---|
| ✅ | 0.95f |
95% size for back cards |
0.90f |
90% size for back cards | |
1.0f |
No scaling |
manager.setScaleInterval(0.95f)Maximum rotation angle of cards in degrees (-360° to 360°).
| Default | Value | Description |
|---|---|---|
| ✅ | 20° |
Default - slight rotation |
0° |
No rotation |
manager.setMaxDegree(20.0f)Directions in which swiping is allowed.
| Default | Value | Description |
|---|---|---|
| ✅ | Direction.HORIZONTAL |
Left and Right |
Direction.VERTICAL |
Top and Bottom | |
Direction.FREEDOM |
All directions |
manager.setDirections(Direction.HORIZONTAL)
manager.setDirections(Direction.VERTICAL)
manager.setDirections(Direction.FREEDOM)Threshold for swipe (0.0f - 1.0f). If the card is dragged beyond this value, it will be swiped.
| Default | Value | Description |
|---|---|---|
| ✅ | 0.3f |
30% - Default |
0.1f |
10% - Very sensitive | |
0.5f |
50% - Less sensitive |
manager.setSwipeThreshold(0.3f)Restriction of swipe directions.
manager.setCanScrollHorizontal(true) // Allow horizontal
manager.setCanScrollVertical(true) // Allow verticalmanager.setCanScrollLeft(true) // Allow left
manager.setCanScrollRight(true) // Allow right
manager.setCanScrollUp(true) // Allow up
manager.setCanScrollDown(true) // Allow downDetermines how swiping can be performed.
| Default | Value | Description |
|---|---|---|
| ✅ | AutomaticAndManual |
Programmatic code and gestures |
Automatic |
Programmatic code only | |
Manual |
Gestures only | |
None |
Disabled |
manager.setSwipeableMethod(SwipeableMethod.AutomaticAndManual)Directions that trigger a rewind when dragging (see Advanced Features).
manager.setDirections(Direction.VERTICAL)
manager.setManualRewindDirections(listOf(Direction.Bottom))Important: manualRewindDirections must not contain any directions that are already enabled in setDirections(...).
Interpolator for the alpha animation of overlay views.
manager.setOverlayInterpolator(LinearInterpolator())
manager.setOverlayInterpolator(AccelerateInterpolator())
manager.setOverlayInterpolator(DecelerateInterpolator())Duration of the fade-in animation for the last card when new data is added (in milliseconds).
manager.setLastItemAppearingAnimationDuration(150) // Default: 150ms
manager.setLastItemAppearingAnimationDuration(0) // DisabledSettings for the swipe animation (see Custom Animations).
val setting = SwipeAnimationSetting.Builder()
.setDirection(Direction.Right)
.setDuration(Duration.Normal.duration)
.setInterpolator(AccelerateInterpolator())
.build()
manager.setSwipeAnimationSetting(setting)Settings for the rewind animation (see Custom Animations).
val setting = RewindAnimationSetting.Builder()
.setDirection(Direction.Bottom)
.setDuration(Duration.Normal.duration)
.setInterpolator(DecelerateInterpolator())
.build()
manager.setRewindAnimationSetting(setting)Current position of the top card (get/set).
val currentPosition = manager.topPosition
manager.topPosition = 5 // Jump to position 5val manager = CardStackLayoutManager(this, listener).apply {
// Stack Layout
setStackLayout(StackLayout.Overlay)
setStackStyle(CardStackStyle.Stack)
setStackFrom(StackFrom.None)
// Visibility
setVisibleCount(3)
setTranslationInterval(8.0f)
setScaleInterval(0.95f)
setMaxDegree(20.0f)
// Swipe
setDirections(Direction.HORIZONTAL)
setSwipeThreshold(0.3f)
setCanScrollHorizontal(true)
setCanScrollVertical(true)
setSwipeableMethod(SwipeableMethod.AutomaticAndManual)
// Overlays
setOverlayInterpolator(LinearInterpolator())
// Animations
setLastItemAppearingAnimationDuration(150)
}
cardStackView.layoutManager = manager