belongs to Maven artifact com.android.support:viewpager:28.0.0-alpha1
ViewPager
public
class
ViewPager
extends ViewGroup
java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | android.support.v4.view.ViewPager |
Layout manager that allows the user to flip left and right
through pages of data. You supply an implementation of a
PagerAdapter
to generate the pages that the view shows.
ViewPager is most often used in conjunction with Fragment
,
which is a convenient way to supply and manage the lifecycle of each page.
There are standard adapters implemented for using fragments with the ViewPager,
which cover the most common use cases. These are
FragmentPagerAdapter
and
FragmentStatePagerAdapter
; each of these
classes have simple code showing how to build a full user interface
with them.
Views which are annotated with the ViewPager.DecorView
annotation are treated as
part of the view pagers 'decor'. Each decor view's position can be controlled via
its android:layout_gravity
attribute. For example:
<android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.PagerTitleStrip android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" /> </android.support.v4.view.ViewPager>
For more information about how to use ViewPager, read Creating Swipe Views with Tabs.
You can find examples of using ViewPager in the API 4+ Support Demos and API 13+ Support Demos sample code.
Summary
Nested classes | |
---|---|
@interface |
ViewPager.DecorView
Annotation which allows marking of views to be decoration views when added to a view pager. |
class |
ViewPager.LayoutParams
Layout parameters that should be supplied for views added to a ViewPager. |
interface |
ViewPager.OnAdapterChangeListener
Callback interface for responding to adapter changes. |
interface |
ViewPager.OnPageChangeListener
Callback interface for responding to changing state of the selected page. |
interface |
ViewPager.PageTransformer
A PageTransformer is invoked whenever a visible/attached page is scrolled. |
class |
ViewPager.SavedState
This is the persistent state that is saved by ViewPager. |
class |
ViewPager.SimpleOnPageChangeListener
Simple implementation of the |
Constants | |
---|---|
int |
SCROLL_STATE_DRAGGING
Indicates that the pager is currently being dragged by the user. |
int |
SCROLL_STATE_IDLE
Indicates that the pager is in an idle, settled state. |
int |
SCROLL_STATE_SETTLING
Indicates that the pager is in the process of settling to a final position. |
Inherited constants |
---|
![]()
android.view.ViewGroup
|
![]()
android.view.View
|
Inherited fields |
---|
![]()
android.view.View
|