开发者

How to Add ViewPager Indicator Headings Like Google+ App

开发者 https://www.devze.com 2023-03-28 07:17 出处:网络
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 transit

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

How to Add ViewPager Indicator Headings Like Google+ App


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.


Google has published his own solution in support library.

Check: PagerTitleStrip, PagerTabStrip


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


I am not 100% sure, but I think it uses the new ViewPager. Maybe you should look at the API 4+ Support Demos:

  • FragmentStatePagerSupport.java
  • FragmentPagerSupport.java
0

精彩评论

暂无评论...
验证码 换一张
取 消