答案 0 :(得分:0)
尝试以下内容。注意实现选项卡选择的侦听器。
TextView title = (TextView)(((LinearLayout ((LinearLayout) mTabLayout.getChildAt(0)).getChildAt(tabPosition)).getChildAt(1));
title.setTextSize(...);
答案 1 :(得分:0)
res/xml
使用textview做任何事情享受......
答案 2 :(得分:0)
显示粗体文本
tabLayout.addOnTabSelectedListener(tabSelectedListener)
private val tabSelectedListener = object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
tab?.view?.children?.forEach {
if (it is TextView) {
it.post {
it.setTypeface(ResourcesCompat.getFont(context, R.font.bold_font_name), Typeface.NORMAL)
}
}
}
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
tab?.view?.children?.forEach {
if (it is TextView) {
it.post {
it.setTypeface(ResourcesCompat.getFont(context, R.font.font_name), Typeface.NORMAL)
}
}
}
}
override fun onTabReselected(tab: TabLayout.Tab?) {}
}