this is used to set indicator's style of tabLayout in Android
- Add the dependencies to your build.gradle file, tabLayoutHelper is avaiable in JCenter:
compile 'com.yongyu.tabLayoutHelper:library:1.0.0'
- Call method what you want, such as :
private void setTabLayout() {
new TabLayoutHelper.Builder(tabLayout)
.setIndicatorColor(Color.BLUE)
.setIndicatorHeight(6)
.setIndicatorWith(100)
.setTabItemMarginLeft(20)
.setIndicatorDrawable(R.drawable.bg_tab_red)
.setNormalTextColor(Color.GRAY)
.setSelectedTextColor(Color.RED)
.setSelectedBold(true)
.setIndicatorMargin(40)
.setTabItemWith(300)
.setTabItemPadding(20)
.setSelectedBackgroundColor(Color.YELLOW)
.setNormalBackgroundColor(Color.DKGRAY)
.setTabItemMarginLeft(20)
.build();
}
详情见博客地址: TabLayout 自定义 Indicator 指示线宽度样式