ViewPager2
class ViewPager2 : ViewGroup
kotlin.Any | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | androidx.viewpager2.widget.ViewPager2 |
ViewPager2 replaces androidx.viewpager.widget.ViewPager
, addressing most of its predecessor’s pain-points, including right-to-left layout support, vertical orientation, modifiable Fragment collections, etc.
Summary
Nested classes | |
---|---|
abstract |
Callback interface for responding to changing state of the selected page. |
abstract |
A PageTransformer is invoked whenever a visible/attached page is scrolled. |
Constants | |
---|---|
static Int |
Value to indicate that the default caching mechanism of RecyclerView should be used instead of explicitly prefetch and retain pages to either side of the current page. |
static Int | |
static Int | |
static Int |
Indicates that the ViewPager2 is currently being dragged by the user, or programmatically via fake drag functionality. |
static Int |
Indicates that the ViewPager2 is in an idle, settled state. |
static Int |
Indicates that the ViewPager2 is in the process of settling to a final position. |
Public constructors | |
---|---|
<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?) |
|
<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int) |
|
<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) |
Public methods | |
---|---|
Unit |
addItemDecoration(@NonNull decor: RecyclerView.ItemDecoration) Add an |
Unit |
addItemDecoration(@NonNull decor: RecyclerView.ItemDecoration, index: Int) Add an |
Boolean |
Start a fake drag of the pager. |
Boolean |
canScrollHorizontally(direction: Int) |
Boolean |
canScrollVertically(direction: Int) |
Boolean |
End a fake drag of the pager. |
Boolean |
fakeDragBy(@Px offsetPxFloat: Float) Fake drag by an offset in pixels. |
CharSequence! | |
RecyclerView.Adapter<RecyclerView.ViewHolder!>? | |
Int |
Returns the currently selected page. |
RecyclerView.ItemDecoration |
getItemDecorationAt(index: Int) Returns an |
Int |
Returns the number of |
Int |
Returns the number of pages that will be retained to either side of the current page in the view hierarchy in an idle state. |
Int | |
Int |
Returns the current scroll state of the ViewPager2. |
Unit |
Invalidates all ItemDecorations. |
Boolean |
Returns |
Boolean |
Returns if user initiated scrolling between pages is enabled. |
Unit | |
Unit |
onViewAdded(child: View!) |