@Override public void setBackgroundResource(@DrawableRes int resId) { super.setBackgroundResource(resId); if (!mDrawFullUnderlineSet) { mDrawFullUnderline = resId == 0; } }
@Override public void setBackgroundColor(int color) { super.setBackgroundColor(color); if (!mDrawFullUnderlineSet) { mDrawFullUnderline = (color & 0xFF000000) == 0; } }
@Override public void setBackgroundDrawable(Drawable d) { super.setBackgroundDrawable(d); if (!mDrawFullUnderlineSet) { mDrawFullUnderline = d == null; } }
@Override public void setTextSpacing(int textSpacing) { if (textSpacing < mMinTextSpacing) { textSpacing = mMinTextSpacing; } super.setTextSpacing(textSpacing); }
@Override public void setPadding(int left, int top, int right, int bottom) { if (bottom < mMinPaddingBottom) { bottom = mMinPaddingBottom; } super.setPadding(left, top, right, bottom); }
@Override void updateTextPositions(int position, float positionOffset, boolean force) { final Rect r = mTempRect; int bottom = getHeight(); int left = mCurrText.getLeft() - mTabPadding; int right = mCurrText.getRight() + mTabPadding; int top = bottom - mIndicatorHeight; r.set(left, top, right, bottom); super.updateTextPositions(position, positionOffset, force); mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF); left = mCurrText.getLeft() - mTabPadding; right = mCurrText.getRight() + mTabPadding; r.union(left, top, right, bottom); invalidate(r); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); final int height = getHeight(); final int bottom = height; final int left = mCurrText.getLeft() - mTabPadding; final int right = mCurrText.getRight() + mTabPadding; final int top = bottom - mIndicatorHeight; mTabPaint.setColor(mTabAlpha << 24 | (mIndicatorColor & 0xFFFFFF)); canvas.drawRect(left, top, right, bottom, mTabPaint); if (mDrawFullUnderline) { mTabPaint.setColor(0xFF << 24 | (mIndicatorColor & 0xFFFFFF)); canvas.drawRect( getPaddingLeft(), height - mFullUnderlineHeight, getWidth() - getPaddingRight(), height, mTabPaint); } }