Пример #1
0
  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    layout.onPageScrolled(position, positionOffset, positionOffsetPixels);

    final View selectedTitle = layout.getChildAt(position);
    if (selectedTitle == null) {
      return;
    }

    final int selectedTitleOffset = (int) (positionOffset * selectedTitle.getWidth());

    int titleLeft = selectedTitle.getLeft() + selectedTitleOffset;
    if (position > 0) {
      titleLeft -= titleOffset;
    }

    int titleRight = selectedTitle.getRight() + selectedTitleOffset;
    if (position < layout.getChildCount() - 1) {
      titleRight += titleOffset;
    }

    final int scrollX = getScrollX();
    if (titleLeft < scrollX) {
      // Tab strip overflows to the left.
      scrollTo(titleLeft, 0);
    } else if (titleRight > scrollX + getWidth()) {
      // Tab strip overflows to the right.
      scrollTo(titleRight - getWidth(), 0);
    }
  }
Пример #2
0
 @Override
 public void setOnTitleClickListener(HomePager.OnTitleClickListener onTitleClickListener) {
   layout.setOnTitleClickListener(onTitleClickListener);
 }
Пример #3
0
 @Override
 public void removeAllPagerViews() {
   layout.removeAllViews();
 }
Пример #4
0
 @Override
 public void onPageSelected(final int position) {
   layout.onPageSelected(position);
 }
Пример #5
0
 @Override
 public void onAddPagerView(String title) {
   layout.onAddPagerView(title);
 }