private void scrollToTab(int position, int positionOffset) { final int tabStripChildCount = mNiceTabStrip.getChildCount(); if (tabStripChildCount == 0 || position < 0 || position >= tabStripChildCount) { return; } View selectedTab = mNiceTabStrip.getChildAt(position); if (selectedTab != null) { int targetScrollX = selectedTab.getLeft() + positionOffset; if (mNiceTabStrip.isTabSelectedCenter()) { targetScrollX -= (mNiceTabStrip.getChildAt(0).getWidth() - selectedTab.getWidth()) / 2; } else if (position > 0 || positionOffset > 0) { targetScrollX -= mTabOffset; } scrollTo(targetScrollX, 0); } }
@Override protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) { super.onSizeChanged(width, height, oldWidth, oldHeight); changeTabLayoutPadding( mNiceTabStrip.isTabSelectedCenter(), mNiceTabStrip.isTabDistributeEvenly()); }