Methods Summary |
---|
public boolean | getDrawFullUnderline()Return whether or not this tab strip will draw a full-width underline.
This defaults to true if no background is set.
return mDrawFullUnderline;
|
int | getMinHeight()
return Math.max(super.getMinHeight(), mMinStripHeight);
|
public int | getTabIndicatorColor()
return mIndicatorColor;
|
protected void | onDraw(android.graphics.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);
}
|
public boolean | onTouchEvent(android.view.MotionEvent ev)
final int action = ev.getAction();
if (action != MotionEvent.ACTION_DOWN && mIgnoreTap) {
return false;
}
// Any tap within touch slop to either side of the current item
// will scroll to prev/next.
final float x = ev.getX();
final float y = ev.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
mInitialMotionX = x;
mInitialMotionY = y;
mIgnoreTap = false;
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(x - mInitialMotionX) > mTouchSlop ||
Math.abs(y - mInitialMotionY) > mTouchSlop) {
mIgnoreTap = true;
}
break;
case MotionEvent.ACTION_UP:
if (x < mCurrText.getLeft() - mTabPadding) {
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
} else if (x > mCurrText.getRight() + mTabPadding) {
mPager.setCurrentItem(mPager.getCurrentItem() + 1);
}
break;
}
return true;
|
public void | setBackgroundColor(int color)
super.setBackgroundColor(color);
if (!mDrawFullUnderlineSet) {
mDrawFullUnderline = (color & 0xFF000000) == 0;
}
|
public void | setBackgroundDrawable(android.graphics.drawable.Drawable d)
super.setBackgroundDrawable(d);
if (!mDrawFullUnderlineSet) {
mDrawFullUnderline = d == null;
}
|
public void | setBackgroundResource(int resId)
super.setBackgroundResource(resId);
if (!mDrawFullUnderlineSet) {
mDrawFullUnderline = resId == 0;
}
|
public void | setDrawFullUnderline(boolean drawFull)Set whether this tab strip should draw a full-width underline in the
current tab indicator color.
mDrawFullUnderline = drawFull;
mDrawFullUnderlineSet = true;
invalidate();
|
public void | setPadding(int left, int top, int right, int bottom)
if (bottom < mMinPaddingBottom) {
bottom = mMinPaddingBottom;
}
super.setPadding(left, top, right, bottom);
|
public void | setTabIndicatorColor(int color)Set the color of the tab indicator bar.
mIndicatorColor = color;
mTabPaint.setColor(mIndicatorColor);
invalidate();
|
public void | setTabIndicatorColorResource(int resId)Set the color of the tab indicator bar from a color resource.
setTabIndicatorColor(getContext().getResources().getColor(resId));
|
public void | setTextSpacing(int textSpacing)
if (textSpacing < mMinTextSpacing) {
textSpacing = mMinTextSpacing;
}
super.setTextSpacing(textSpacing);
|
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);
|