Q:

astuetz / PagerSlidingTabStrip Wrong selected tab when I rotate device

When I rotate the device and If I have selected some tab other than the first or last it shows me the wrong position of tabs.
but when I make a little touch gesture it updates itself. Do you know how to fix this.

A:

This is very simple see below 
getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        @Override
        public void onGlobalLayout() {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }

            currentPosition = pager.getCurrentItem();
            currentPositionOffset = 0f; // ----> just put this line
            scrollToChild(currentPosition, 0);
        }
    });

