Skip to content

LordZoltan/PagerSlidingTabStrip.Net

Repository files navigation

PagerSlidingTabStrip.Net

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).

Using Nuget?

This project is available as a ready-rolled Nuget package (for Android 2.2+ projects) as PagerSlidingTabStrip.Net on Nuget.Org.

1.2.x release breaking change

James Ottaway very kindly followed up Issue #1, which involved changing a couple of the attributes supported by the control. In the process the project was changed to reference the newer Xamarin.Android.Support.v4 reference library (via nuget) rather than the old Mono.Android.Support.v4 reference library.

These are both breaking changes - the first is simply a case of renaming attributes in your layout files. The second might not hit you at all, but is a concern if you are using another binary which references the older Mono.Android.Support.v4 library. You'll either need a different version of that library that references the newer support library wrapper, or get hold of the source for the offending binary and build it yourself to use the correct one.

Example

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

Screenshot 1  Screenshot 2

And showing icons instead of text:

Screenshot 3

Usage

  1. Include the PagerSlidingTabStrip in your view. this should usually be placed adjacent to the ViewPager it represents:

    <pagerslidingtabstrip.PagerSlidingTabStrip
    	android:id="@+id/tabs"
    	android:layout_width="match_parent"
    	android:layout_height="48dip" />
    
  2. In your OnCreate/OnCreateView(fragment) bind the widget to the ViewPager (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);
    
  3. (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).

Ported by

  • Andras Zoltan (@RealLordZoltan)

With contributions from

Many thanks!

Port Notes

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 developed this port specifically for another project I was working on at the time - and as a result I have added features to this library that were not present in the original.

Originally developed by

About

Port of Java project of the same name by Andreas Stütz (https://github.com/astuetz/PagerSlidingTabStrip) for Xamarin.Android, written in C# .Net.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •