广告
返回顶部
首页 > 资讯 > 移动开发 >com.google.android.material.tabs.TabLayout 选择tab 加粗字体加大
  • 765
分享到

com.google.android.material.tabs.TabLayout 选择tab 加粗字体加大

comgoogle字体tablayoutmaterialtabsAndroid 2022-06-06 13:06:42 765人浏览 薄情痞子
摘要

引用: 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

作者:Liuyz0420


--结束END--

本文标题: com.google.android.material.tabs.TabLayout 选择tab 加粗字体加大

本文链接: https://www.lsjlt.com/news/29459.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作