Exemplo n.º 1
0
  /**
   * At this point the scrolling direction is determined and every child is interpolated to its
   * previous or next position
   */
  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    final int count = getChildCount();

    final int currentScrollX = mPosition * (mPager.getWidth() + mPager.getPageMargin());

    Direction dir = Direction.Center;

    float x = 0.0f;

    if (mPager.getScrollX() < currentScrollX) {
      dir = Direction.Left;
      x = 1 - positionOffset;
    } else if (mPager.getScrollX() > currentScrollX) {
      dir = Direction.Right;
      x = positionOffset;
    }

    for (int i = 0; i < count; i++) {
      ViewPagerTab tab = (ViewPagerTab) getChildAt(i);

      final float y0 = tab.currentPos;
      float y1 = 0.0f;

      if (dir == Direction.Left) y1 = tab.nextPos;
      else if (dir == Direction.Right) y1 = tab.prevPos;
      else y1 = tab.currentPos;

      tab.layoutPos = (int) (y0 + (y1 * x - y0 * x));
    }

    this.requestLayout();
  }
 public void a(int j, float f1, int k) {
   s.a(k + j * (r.getWidth() + r.getPageMargin()));
   for (int l = 0; l < p.size(); l++) {
     TabInfo tabinfo = (TabInfo) p.get(l);
     if (tabinfo.b != null) {
       tabinfo.b.e();
     }
   }
 }
 @Override
 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
   mIndicator.onScrolled(
       (mPager.getWidth() + mPager.getPageMargin()) * position + positionOffsetPixels);
   for (int i = 0; i < mTabs.size(); i++) {
     TabInfo tab = mTabs.get(i);
     if (tab.fragment != null) {
       tab.fragment.onScrolled();
     }
   }
 }