I created a library to satisfy the need for a page indicator in ViewPager. My library contains a View called DotIndicator. To use my library, add compile 'com.matthew-tamlin:sliding-intro-screen:3.2.0' to the gradle assembly file.
You can add a view to the layout by adding the following:
<com.matthewtamlin.sliding_intro_screen_library.indicators.DotIndicator android:layout_width="wrap_content" android:layout_height="wrap_content" app:numberOfDots=YOUR_INT_HERE app:selectedDotIndex=YOUR_INT_HERE/>
The above code perfectly reproduces the functionality of the points on the Google Launcher home screen, however, if you want to further customize it, you can add the following attributes:
app:unselectedDotDiameter and app:selectedDotDiameter to set point diametersapp:unselectedDotColor and app:selectedDotColor to set dot colorsapp:spacingBetweenDots to change the distance between pointsapp:dotTransitionDuration to set the time to animate changes from small to large (and vice versa)
In addition, a view can be created programmatically using:
DotIndicator indicator = new DotIndicator(context);
There are methods for changing properties similar to attributes. To refresh the indicator to display another page as selected, simply call the indicator.setSelectedItem(int, true) ViewPager.OnPageChangeListener.onPageSelected(int) from within ViewPager.OnPageChangeListener.onPageSelected(int) .
Here is a usage example:

If you're interested, the library was actually designed to create built-in screens like the one shown in the above file.
The Github source is available here: https://github.com/MatthewTamlin/SlidingIntroScreen
source share