Android - Google Drive like Page Indicators

    The recent updates to Google apps in Android have a brand logo along with an intro pages. These highlight the features across pages. Like many view pager implementations, it has a page indicators. The indicators are highlighted based on the current focus page. Android doesn't offer an out of box PageIndicator API to work with ViewPagers. Google drive (2.3.357.23.34) uses a set of images hosted under a LinearLayout for page indicators.





   One way to achieve this is by having a custom linear layout add a number of child ImageViews based on the number of pages returned by the ViewPager's adapter getCount(). This has to be updated any time the adapter is invalidated or a data set change is requested. Besides, the custom linear layout has a register for an OnPageChangeListener to get the index of the active page and set an appropriate image resource for active and inactive page indicators.

No comments: