Disable ActionBar tab indicator programmatically

拟墨画扇 提交于 2019-12-04 16:11:30
mmlooloo

If I were you I would not use ActionBar tab because it is deprecated from api 21 and also it is not working on tablets as you may expect. I would use

1)PagerSlidingTabStrip

2)SlidingTabsBasic

(another version of SlidingTabsBasic is here you must add SlidingTabLayout.java and SlidingTabStrip.java)

If you want to use PagerSlidingTabStrip you can use pstsIndicatorColor or

public void setIndicatorColor(int indicatorColor) 

public void setIndicatorColorResource(int resId)

from the library.

If you want to use SlidingTabsBasic you can use

SlidingTabLayout tabs = (SlidingTabLayout) findViewById(R.id.tabs); 
tabs.setViewPager(viewpager); 

tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {

    @Override
    public int getIndicatorColor(int position) {
    return getResources().getColor(R.color.white);  
    }

    @Override
    public int getDividerColor(int position) {
    return getResources().getColor(R.color.white);
    }
});
Nitish

Applying the style as answered here disabled the indicator as well. One solution fixed two issues for me :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!