使用textColor
屬性; 在res /價值/ styles.xml創建一個新的風格:
<style name="Pager">
<item name="android:textColor">#4DB849</item>
<item name="android:indicatorColor">#E95044</item>
</style>
你會得到一個綠色的標題和紅色指示燈。
您可能希望看到ViewPagerIndicator
要改變你必須改變的onDraw(帆布油畫)方法的指標。
這是源代碼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文檔。
Custom Drawing
您試過了什麼,以及您遇到過哪些具體問題?例如,您是否成功創建了「PagerTitleStrip」的分支? – CommonsWare 2014-11-05 11:49:17
http://stackoverflow.com/questions/10008309/android-implement-a-page-counter-like-the-one-on-the-home-screen 試試這個 – 2014-11-05 11:50:48
你想用點替換指示條, 是對的嗎 ? – vovahost 2014-11-05 12:16:08