Category: Blog, Android, Development

How to Create PagerTitleStrip with Current Page Indicator Only

How to Create PagerTitleStrip with Current Page Indicator Only

Create PagerTitleStrip only with Current Page Indicator. Find out, how to do this!

Original PagerTitleStrip displays indicators of the current, next, and previous pages of the ViewPager, but sometimes only current is needed. It looks like the others can be hidden by setting non-primary alpha value to zero but despite that shadows can appear.

TextViews containing mentioned indicators are not exposed, so it is not possible to set their visibility even by extending PagerTitleStrip. However, it is possible to create an own class in android.support.v4.view hierarchy.

Code ready to use is available as a gist.

About the author

Karol Wrótniak

Karol Wrótniak

Mobile Developer

Flutter & Android Developer with 12 years of experience. A warhorse with impressive experience and skills in native and Flutter app development. Karol is probably the most active contributor to open source libraries you've ever met. He develops Gradle plugins and Bitrise steps, and he is engaged in many projects, in particular those related to testing.

Karol has been engaged as a speaker in many events and meetups like DevFest, 4Developers Wrocław, JDD Conference, Linux Academy, and more. He is an active member of Google Developers Group Wrocław, Flutter Wrocław, and Bitrise User Group.