AndroidViewPagerIndicator
lastmod 2018-08-17created 2014-03-055 edits
Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability of content.
Usage
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 (or onCreateView for a fragment), bind the indicator to the ViewPager.
//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.
vpiCirclePageIndicatorStyle Style Setting
A warning message like the one below may be printed.
In this case, you need to set vpiTabPageIndicatorStyle as shown below.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@style/Theme.Sherlock.Light">
<item name="vpiTabPageIndicatorStyle">@style/TabStyle</item>
</style>
<style name="TabStyle" parent="Widget.TabPageIndicator">
<item name="android:textColor">#FF33AA33</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">italic</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
</style>
</resources>