使用textColor
属性;在 res/values/styles.xml 中创建一个新样式:
<style name="Pager">
<item name="android:textColor">#4DB849</item>
<item name="android:indicatorColor">#E95044</item>
</style>
您将获得一个绿色标题和一个红色指示器。
您可能想查看 ViewPagerIndicator
要更改指标,您必须更改 onDraw(Canvas canvas) 方法。这是PagerTabStrip.java
的源代码。
@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);
}
}
您必须更改此行:
canvas.drawRect(left, top, right, bottom, mTabPaint);
替换为以下内容时测试是否有一个点:
canvas.drawCircle(left, top, 15, mTabPaint);
要绘制自定义视图,请查看 Android 文档。
自定义绘图