Remove TabIndicator from PagerTabStrip in a ViewPager
Asked Answered
M

3

5

I have a viewpager that uses a PagerTabStrip to indicate the current page. However, I don't want the default indicator to be present. (Underline underneath the page title)

I've tried a few different methods to remove it, but none of them seem to work.

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

also

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

and

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

None of these seems to work. Instead it gives me a black indicator instead. Any help would be appreciated. THanks!

Maillot answered 27/11, 2012 at 19:9 Comment(0)
C
5

By looking at the source of PagerTabStrip. I have found the following method:

/**
 * 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();
}

I have not tested this, but I suppose this should work. Leave a comment if it doesn't.

Capture answered 7/12, 2012 at 12:9 Comment(3)
Thanks! I was able to get it working with your help. I'll post my final source in a bit once I confirm everything is working.Maillot
setDrawFullUnderline divides the PagerTitleStrip. I was trying to remove the Tab Indicator underline setTabIndicatorColor, Android Docs says "Color to set as an 0xRRGGBB value. The high byte (alpha) is ignored."Lionhearted
Tested, this is not the answer.Colic
C
2

PagerTitleStrip is what you need. It has the same functionality, just without the underline color.

Cincture answered 30/12, 2013 at 15:26 Comment(0)
E
1

If you don't want use PagerTitleStrip, you can set the Indicator Color to same color of Background PagerTabStrip

Elkeelkhound answered 29/10, 2014 at 16:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.