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

问题描述 投票:0回答:1

我在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>

即使我已经为其设置样式

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

但不起作用

android xml material-design android-tablayout
1个回答
2
投票

自定义样式

  <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>

标签布局xml代码

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tab"
    style="@style/customTabLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
© www.soinside.com 2019 - 2024. All rights reserved.