TabPageIndicator Text Font

前端 未结 3 1670
故里飘歌
故里飘歌 2021-01-07 02:51

I\'m using ViewPagerIndicator, and haven\'t had any luck, so I\'ll ask here. Is there a way to change the font for the Tabs in a TabPageIndicator?

3条回答
  •  逝去的感伤
    2021-01-07 03:54

    There is no need to use a third-party lib nor to change ViewPagerIndicator lib.

    TabPageIndicator has a single ViewGroup child which contains the tab Views so you can use this code to change the font:

    ViewGroup vg = (ViewGroup) indicator.getChildAt(0);
    int vgChildCount = vg.getChildCount();
    for (int j = 0; j < vgChildCount; j++) {
        View vgChild = vg.getChildAt(j);
        if (vgChild instanceof TextView) {
            ((TextView) vgChild).setTypeface(YOUR_FONT);
        }
    }
    

提交回复
热议问题