Carousel
class Carousel : MotionHelper
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | androidx.constraintlayout.widget.ConstraintHelper | |||
| ↳ | androidx.constraintlayout.motion.widget.MotionHelper | |||
| ↳ | androidx.constraintlayout.helper.widget.Carousel |
Carousel works within a MotionLayout to provide a simple recycler like pattern. Based on a series of Transitions and callback to give you the ability to swap views.
Summary
Nested types |
|---|
interface Carousel.AdapterAdapter for a Carousel |
Public constructors |
|---|
Carousel(context: Context!, attrs: AttributeSet!) |
Carousel(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
Public functions |
|
|---|---|
Int |
getCount()Returns the number of elements in the Carousel |
Int |
Returns the current index |
Boolean |
Returns whether it's a infinite Carousel |
Unit |
jumpToIndex(index: Int)Jump to the given index without any animation |
Unit |
onTransitionChange(Called when a drawer's position changes. |
Unit |
onTransitionCompleted(motionLayout: MotionLayout!, currentId: Int)Called when a drawer has settled completely a state. |
Unit |
refresh()Rebuilds the scene |
Unit |
setAdapter(adapter: Carousel.Adapter!) |
Unit |
setInfinite(infiniteCarousel: Boolean)A setter method for whether it should be a infinite Carousel. |
Unit |
transitionToIndex(index: Int, delay: Int)Transition the carousel to the given index, animating until we reach it. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|---|
Constants
Public constructors
Public functions
getCount
fun getCount(): Int
Returns the number of elements in the Carousel
| Returns | |
|---|---|
Int |
number of elements |
getCurrentIndex
fun getCurrentIndex(): Int
Returns the current index
| Returns | |
|---|---|
Int |
current index |
isInfinite
fun isInfinite(): Boolean
Returns whether it's a infinite Carousel
| Returns | |
|---|---|
Boolean |
true if it's a infinite Carousel, otherwise, false. |
jumpToIndex
fun jumpToIndex(index: Int): Unit
Jump to the given index without any animation
| Parameters | |
|---|---|
index: Int |
index of the element we want to reach |
onTransitionChange
fun onTransitionChange(
motionLayout: MotionLayout!,
startId: Int,
endId: Int,
progress: Float
): Unit
Called when a drawer's position changes.
| Parameters | |
|---|---|
motionLayout: MotionLayout! |
The TransitionLayout view that was moved |
startId: Int |
the id of the start state (or ConstraintSet). Will be -1 if unknown. |
endId: Int |
the id of the end state (or ConstraintSet). |
progress: Float |
The progress on this transition, from 0 to 1. |
onTransitionCompleted
fun onTransitionCompleted(motionLayout: MotionLayout!, currentId: Int): Unit
Called when a drawer has settled completely a state. The TransitionLayout is interactive at this point.
| Parameters | |
|---|---|
motionLayout: MotionLayout! |
Drawer view that is now open |
currentId: Int |
the id it has reached |
setInfinite
fun setInfinite(infiniteCarousel: Boolean): Unit
A setter method for whether it should be a infinite Carousel. Remember to call refresh after calling this method.
| Parameters | |
|---|---|
infiniteCarousel: Boolean |
true if it should be a infinite Carousel, otherwise, false |
transitionToIndex
fun transitionToIndex(index: Int, delay: Int): Unit
Transition the carousel to the given index, animating until we reach it.