如何以小写字母设置标签栏上的文本?

How to set text on tab bar in small letters?

我写了视频,但在选项卡中它以视频的形式出现 capitals.I 希望它像 "Videos"

TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Videos"));
tabLayout.addTab(tabLayout.newTab().setText("Notes"));

使用这个风格LayLayout

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
      <item name="tabTextAppearance">@style/MyCustomTextAppearance</item>
</style>

制作标签textAllCaps

<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
      <item name="textAllCaps">false</item>
</style>

好吧,如果我没有误解你必须创建一个 styles.xml 如下:

<style name="CustomTabs" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">YOUR_TEXT_SIZE</item>
    <item name="android:textAllCaps">false</item>
</style>

然后在 layout 中放置 TabLayout 的位置添加:

app:tabTextAppearance="@style/CustomTabs"

如果您不想显示没有大写字母的标题,您还必须添加 style 这个:

<item name="android:textAllCaps">false</item>

解决方案

最好的方法是将此添加到您的 TabLayout xml

app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"