android:textAllCaps=“false”不适用于 com.google.android.material.tabs.TabLayout

moz*_*afr 1 xml android material-design android-tablayout

我在 com.google.android.material.tabs.TabItem 中设置了 android:textAllCaps="false" ,认为它仅显示全部大写的选项卡标题。

如何删除所有大写字母?

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <com.google.android.material.tabs.TabItem
        android:id="@+id/TabWeekly"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="@string/Weekly"
        android:textAllCaps="false"
        android:theme="@style/CustomTextAppearanceTab" />

    <com.google.android.material.tabs.TabItem
        android:id="@+id/TabMonthly"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="@string/Monthly"
        android:textAllCaps="false"
        android:theme="@style/CustomTextAppearanceTab" />

</com.google.android.material.tabs.TabLayout>
Run Code Online (Sandbox Code Playgroud)

即使我已经为它设定了风格

<style name="CustomTextAppearanceTab" parent="TextAppearance.Design.Tab">
       <item name="textAllCaps">false</item>
       <item name="android:textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但它不起作用

Mai*_*tri 7

定制风格

  <style name="customTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabTextAppearance">@style/TabTextAppearance</item>
</style>

<style name="TabTextAppearance" parent="@android:style/TextAppearance.Widget.TabWidget">
    <item name="android:textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

选项卡布局 xml 代码

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tab"
    style="@style/customTabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

  • 父样式**错误**。您应该对选项卡使用“Widget.MaterialComponents.TabLayout”,对“tabTextAppearance”使用“TextAppearance.MaterialComponents.Button” (4认同)