Android TabLayout与ViewPager搭配使用英文标题默认大写解决方案

问题:TabLayout与ViewPager搭配使用时英文标题默认大写

目的:让TabLayout的英文标题既能显示大写又能显示小写

步骤:

  1. 在style.xml中实现一个样式,指定parent为TextAppearance.Design.Tab,并设置标签属性<item name="textAllCaps">false</item>

    <style name="TabTextStyle" parent="TextAppearance.Design.Tab">
            <item name="textAllCaps">false</item>
    </style>
    
  2. 在布局的TabLayout标签中使用app:tabTextAppearance指定Tab的文字样式

     <android.support.design.widget.TabLayout
                app:tabTextAppearance="@style/TabTextStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
    

附上TabLayout默认字体样式代码

<style name="TextAppearance.Design.Tab" parent="TextAppearance.AppCompat.Button">
        <item name="android:textSize">@dimen/design_tab_text_size</item>
        <item name="android:textColor">?android:textColorSecondary</item>
        <item name="textAllCaps">true</item>
</style>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容