5

我有一个使用 PagerTabStrip 来指示当前页面的 viewpager。但是,我不希望出现默认指示器。(页面标题下划线)

我尝试了几种不同的方法来删除它,但它们似乎都不起作用。

PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip); pts.setTabIndicatorColor(getResources().getColor(android.R.color.transparent));

PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip); pts.setTabIndicatorColor(Color.parseColor("#80000000"));

PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip); pts.setTabIndicatorColor(Color.TRANSPARENT);

这些似乎都不起作用。相反,它给了我一个黑色指示器。任何帮助,将不胜感激。谢谢!

4

3 回答 3

5

通过查看 PagerTabStrip 的来源。我找到了以下方法:

/**
 * Set whether this tab strip should draw a full-width underline in the
 * current tab indicator color.
 *
 * @param drawFull true to draw a full-width underline, false otherwise
 */
public void setDrawFullUnderline(boolean drawFull) {
    mDrawFullUnderline = drawFull;
    mDrawFullUnderlineSet = true;
    invalidate();
}

我没有对此进行测试,但我想这应该可以。如果没有,请发表评论。

于 2012-12-07T12:09:48.170 回答
2

PagerTitleStrip是您所需要的。它具有相同的功能,只是没有下划线颜色。

于 2013-12-30T15:26:01.057 回答
1

如果您不想使用PagerTitleStrip,您可以将指示器颜色设置为与背景PagerTabStrip相同的颜色

于 2014-10-29T16:26:47.290 回答