コード例 #1
0
 public PagerTabStrip(Context paramContext, AttributeSet paramAttributeSet) {
   super(paramContext, paramAttributeSet);
   mTabPaint.setColor(mIndicatorColor);
   float f = getResourcesgetDisplayMetricsdensity;
   mIndicatorHeight = ((int) (3.0F * f + 0.5F));
   mMinPaddingBottom = ((int) (6.0F * f + 0.5F));
   mMinTextSpacing = ((int) (64.0F * f));
   mTabPadding = ((int) (16.0F * f + 0.5F));
   mFullUnderlineHeight = ((int) (1.0F * f + 0.5F));
   mMinStripHeight = ((int) (f * 32.0F + 0.5F));
   mTouchSlop = ViewConfiguration.get(paramContext).getScaledTouchSlop();
   setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom());
   setTextSpacing(getTextSpacing());
   setWillNotDraw(false);
   mPrevText.setFocusable(true);
   mPrevText.setOnClickListener(
       new View.OnClickListener() {
         public final void onClick(View paramAnonymousView) {
           mPager.setCurrentItem(mPager.getCurrentItem() - 1);
         }
       });
   mNextText.setFocusable(true);
   mNextText.setOnClickListener(
       new View.OnClickListener() {
         public final void onClick(View paramAnonymousView) {
           mPager.setCurrentItem(mPager.getCurrentItem() + 1);
         }
       });
   if (getBackground() == null) {
     mDrawFullUnderline = true;
   }
 }
コード例 #2
0
  public PagerTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);

    mIndicatorColor = mTextColor;
    mTabPaint.setColor(mIndicatorColor);

    // Note: this follows the rules for Resources#getDimensionPixelOffset/Size:
    //       sizes round up, offsets round down.
    final float density = context.getResources().getDisplayMetrics().density;
    mIndicatorHeight = (int) (INDICATOR_HEIGHT * density + 0.5f);
    mMinPaddingBottom = (int) (MIN_PADDING_BOTTOM * density + 0.5f);
    mMinTextSpacing = (int) (MIN_TEXT_SPACING * density);
    mTabPadding = (int) (TAB_PADDING * density + 0.5f);
    mFullUnderlineHeight = (int) (FULL_UNDERLINE_HEIGHT * density + 0.5f);
    mMinStripHeight = (int) (MIN_STRIP_HEIGHT * density + 0.5f);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    // Enforce restrictions
    setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom());
    setTextSpacing(getTextSpacing());

    setWillNotDraw(false);

    mPrevText.setFocusable(true);
    mPrevText.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
          }
        });

    mNextText.setFocusable(true);
    mNextText.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            mPager.setCurrentItem(mPager.getCurrentItem() + 1);
          }
        });

    if (getBackground() == null) {
      mDrawFullUnderline = true;
    }
  }