Skip to content

Dynogic/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.

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)

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.

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

Languages

  • Java 94.5%
  • C# 5.4%
  • HTML 0.1%