How to make Pager Sliding Tab Strip with always 3 categories equally fit in screen?

564 views Asked by At

I have a ViewPager with a SlidingTabLayout class and a SlidingTabStrip class. The FragmentPagerAdapter uses by this ViewPager allow to show 367 entries (actually I want to show a Calendar). My SlidingTabLayout is not scralable; I added these modifications for that:

@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // if we can scroll pass the event to the superclass
            if (mScrollable) return super.onTouchEvent(ev);
            // only continue to handle the touch event if scrolling enabled
            return mScrollable; // mScrollable is always false at this point
        default:
            return super.onTouchEvent(ev);
    }
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    // Don't do anything with intercepted touch events if
    // we are not scrollable
    if (!mScrollable) return false;
    else return super.onInterceptTouchEvent(ev);
}

And now, I want to show just 3 categories in Sliding Tab Strip at each time, like this example:

enter image description here

How can I do that please ?

1

There are 1 answers

1
Maximosaic On

I achieved this result with

SlidingTabLayout slidingTabLayout = ...  ;
slidingTabLayout.setDistributeEvenly(true);

Hopefully this helps.