## 引用版本是:
implementation 'io.github.h07000223:flycoTabLayout:3.0.0'
## 使用是:
com.flyco.tablayout.CommonTabLayout
<com.flyco.tablayout.CommonTabLayout
android:id="@+id/tab_layout_ct"
android:layout_width="wrap_content"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tl_indicator_color="@color/global_color"
app:tl_indicator_corner_radius="3dp"
app:tl_indicator_height="3dp"
app:tl_indicator_width="35dp"
app:tl_tab_space_equal="false"
app:tl_textBold="SELECT"
app:tl_textSelectColor="@color/global_color"
app:tl_textUnselectColor="@color/black"
app:tl_textsize="@dimen/r_toolbar_title"
app:tl_underline_color="@color/black"
app:tl_underline_height="0dp" />
页面代码:
mFragmentBaseFragment =
FragmentChangeBaseManager(childFragmentManager, R.id.fr_fragment, mFragmentList)
val tabs: ArrayList<CustomTabEntity> =
arrayListOf(
MyCustomTab("布草", 0),
MyCustomTab("标签", 1),
MyCustomTab("异常", 2)
)
binding?.tabLayoutCt?.setTabData(tabs)
binding?.tabLayoutCt?.setOnTabSelectListener(object : OnTabSelectListener {
...
}
)
问题:
按理说:
app:tl_textBold="SELECT"
这个设置select之后,选中的标题文字会加粗,但是,选中tab的加粗效果第一次进来的时候无效的bug
解决:
代码中首次加载之后,重新手动代码设置一下当前选中碎片0:
(在执行完成监听: binding?.tabLayoutCt?.setOnTabSelectListener之后加上这setCurrentTab)
binding?.tabLayoutCt?.currentTab=0
首次加载加粗效果: