引用: https://blog.csdn.net/qq_34906385/article/details/93524163 app:tab
引用: https://blog.csdn.net/qq_34906385/article/details/93524163
app:tabIndicatorColor :指示线的颜色
app:tabIndicatorHeight : 指示线的高度
app:tabIndicatorFullWidth="false" 指示线是否铺满宽度
app:tabSelectedTextColor : tab选中时的字体颜色
app:tabTextColor="@color/colorPrimary" :未选中字体颜色
app:tabBackground="color" : 整个tablayout颜色
app:tabMode="scrollable" : 默认是fixed,固定的;scrollable:可滚动的
//监听一定要在setupWithViewPager方法之前添加
binding.tablayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
changeTabTextView(tab, true);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
changeTabTextView(tab, false);
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// 选中第一个
changeTabTextView(binding.tablayout.getTabAt(0), true);
public void changeTabTextView(TabLayout.Tab tab, boolean isBold) {
View view = tab.getCustomView();
if (null == view) {
tab.setCustomView(R.layout.tab_layout_text);
}
TextView textView = tab.getCustomView().findViewById(Android.R.id.text1);
if (isBold) {
textView.setTextAppearance(context, R.style.TabLayoutBoldTextSize);
} else {
textView.setTextAppearance(context, R.style.TabLayoutNORMalTextSize);
}
}
17sp
bold
#fc5a44
15sp
normal
#24272E
--结束END--
本文标题: com.google.android.material.tabs.TabLayout 选择tab 加粗字体加大
本文链接: https://www.lsjlt.com/news/29459.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0