Android PagerSlidingTabStrip (default Material Design)
Interactive paging indicator widget, compatible with the ViewPager from the Android Support Library.
Usage
For a working implementation of this project see the sample/
folder.
- Include the following dependency in your
build.gradle
file.
Or add the library as a project. I tried to send a pull request, but looks like the original developer doesn't maintain it anymore.
- Include the
PagerSlidingTabStrip
widget in your layout. This should usually be placed above theViewPager
it represents.
- In your
onCreate
method (oronCreateView
for a fragment), bind the widget to theViewPager
:
That's all you need to do, but if you want to use your own tabs, then...
-
If your adapter implements the interface
CustomTabProvider
you can paste your custom tab view/s.-
In case the the view returned contains the id
R.id.psts_tab_title
, this view should be aTextView
and
will be used to placed the title and set the view state (pressed/selected/default). -
If you don't want the library manage your TextView title for the tab, use a different id than
R.id.psts_tab_title
in your tab layout. -
The interface provide callbacks for selection and unselection of tabs as well.
-
If your adapter doesn't implement the interface
CustomTabProvider
the default tab will be used, which is aTextView
with idR.id.psts_tab_title
).
-
-
(Optional) If you use an
OnPageChangeListener
with your view pager
you should set it in the widget rather than on the pager directly.