Paging indicator widgets that are compatible with the ViewPager
from the
Android Support Library to improve discoverability of content.
Try out the sample application on the Android Market.
These widgets can also be used in conjunction with ActionBarSherlock!
For a working implementation of this project see the sample/
folder.
-
Include one of the widgets in your view. This should usually be placed adjacent to the
ViewPager
it represents.<com.viewpagerindicator.TitlePageIndicator android:id="@+id/titles" android:layout_height="wrap_content" android:layout_width="fill_parent" />
-
In your
onCreate
method (oronCreateView
for a fragment), bind the indicator to theViewPager
.//Set the pager with an adapter ViewPager pager = (ViewPager)findViewById(R.id.pager); pager.setAdapter(new TestAdapter(getSupportFragmentManager())); //Bind the title indicator to the adapter TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles); titleIndicator.setViewPager(pager);
-
(Optional) If you use an
OnPageChangeListener
with your view pager you should set it in the indicator rather than on the pager directly.//continued from above titleIndicator.setOnPageChangeListener(mPageChangeListener);
There are three ways to style the look of the indicators.
- Theme XML. An attribute for each type of indicator is provided in which you can specify a custom style.
- Layout XML. Through the use of a custom namespace you can include any desired styles.
- Object methods. Both styles have getters and setters for each style attribute which can be changed at any point.
Each indicator has a demo which creates the same look using each of these methods.
Install-Package Naxam.ViewPageIndicator.Droid
This project depends on the ViewPager
class which is available in the
Android Support Library or ActionBarSherlock. Details for
including one of those libraries is available on their respecitve web sites.
- Jake Wharton - Author of original Java library
- Patrik Åkerfeldt - Author of ViewFlow, a precursor to the ViewPager, which supports paged views and is the original source of both the title and circle indicators.
- Francisco Figueiredo Jr. - Idea and first implementation for fragment support via ViewPager.
Copyright (c) 2017 NAXAM
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.