예제 #1
0
 private View getNeededView(int position) {
   if (mTabProvider != null && mTabProvider instanceof TitleIconTabProvider) {
     final int imageViewId = ((TitleIconTabProvider) mTabProvider).getTextOrImageViewId();
     return mNiceTabStrip.getChildAt(position).findViewById(imageViewId);
   } else {
     return mNiceTabStrip.getChildAt(position);
   }
 }
예제 #2
0
  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);
    }
  }