Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add ViewPager Indicator Headings Like Google+ App

Tags:

android

My goal is to create a screen similar in function to the Stream page in the Google+ app (picture below for those unfamiliar). For the paging, I am using a custom ViewGroup so that it has smooth transitions that "follow your finger" rather than just snapping to the destination after the fling gesture has been made.

Question

Currently, I am going the route of using some TranslateAnimations to move the headings ("Nearby," "All circles," and "Incoming" in the screenshot) once a new page has been selected. This creates a couple of problems: the center heading doesn't follow the user's finger (as you can see the "All circles" heading does in the screenshot), and if the user begins on a page other than the middle one, I have not found an easy way to offset all of the animations temporarily without running them first since the animations do not move the actual views.

Am I going about this the correct way, or is there a much simpler way of accomplishing this that I am overlooking?

Thanks

like image 731
Glendon Trullinger Avatar asked Aug 12 '11 20:08

Glendon Trullinger


3 Answers

After hours of searching and a little luck with search terms, I came across A Google+ like ViewPager page indicator.

I also came across Android ViewPager Indicator, created by the same developer who wrote ActionBarSherlock. Has a ton of examples, and is pretty easy to integrate with the FragmentPagerAdapter.

like image 157
Glendon Trullinger Avatar answered Nov 09 '22 04:11

Glendon Trullinger


Google has published his own solution in support library.

Check: PagerTitleStrip, PagerTabStrip

like image 32
fones Avatar answered Nov 09 '22 02:11

fones


Have just used ViewPagerIndicator solution and its very nice and smooth. You can demo the effect by looking at the demo from the Android Market here

like image 36
Kurru Avatar answered Nov 09 '22 03:11

Kurru