Want a full overview of the control, why it exists, and how to customise it more? Go to the Wiki!
An enhanced tab strip for view pagers, offering control over tab background, highlight colour, divider colour and much more. The tabs can scroll in their own right, and the indicator slides smoothly between tabs as pages are changed, in the same way as is seen in the Play Store(tm) version 4.4.22.
This is a port of the Java project of (almost) the same name by Andreas Stütz here.
The example application is, also, a straight port as well - showing the same features (now with some additions).
This project is available as a ready-rolled Nuget package (for Android 2.2+ projects) as PagerSlidingTabStrip.Net on Nuget.Org.
See Andreas' demo, available on the Play Store (see the project page), for an accurate representation of what you can achieve with this library.
The Example project in the sample/
folder builds an app that's functionally the same:
Note - since these screenshots were done, the app has been updated with an extra set of menu options that demonstrate how to change the number of tabs dynamically
And showing icons instead of text:
-
Include the
PagerSlidingTabStrip
in your view. this should usually be placed adjacent to theViewPager
it represents:<pagerslidingtabstrip.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dip" />
-
In your
OnCreate
/OnCreateView
(fragment) bind the widget to theViewPager
(note this is taken from the Example)._tabs = FindViewById<PagerSlidingTabStrip.PagerSlidingTabStrip>(Resource.Id.tabs); _pager = FindViewById<ViewPager>(Resource.Id.pager); _adapter = new MyPagerAdapter(SupportFragmentManager); // Set the pager with an adapter: _pager.Adapter = _adapter; //Set the pager to the tabs control: _tabs.SetViewPager(_pager);
-
(Optional) If you use the
PageScrolled
/PageScrollStateChanged
/PageSelected
events from your view pager, you should now subscribe instead to the same events on the_tabs
object (it proxies the events from the pager).
- Andras Zoltan (@RealLordZoltan)
I've tried where possible to translate Java paradigms to .Net paradigms in a similar way to Xamarin's own methodology. However, my main purpose was to get it working, so there might be some things I've missed.
I might add features to this library as required by another project that I'm working on - but only in a way that would enhance other apps of course.
- Andreas Stuetz - [email protected]