解决 Button 和 TabLayout 英文自动大写的问题

来源:互联网 发布:编曲软件排名 编辑:程序博客网 时间:2024/05/17 06:58

在使用 ButtonTabLayout 时,英文字体会自动变成大写,查看 Android 源码发现,TabLayout 的默认属性中设置了textAllCapstrue


TabLayout.java

mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance,                R.style.TextAppearance_Design_Tab);

styles.xml

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

解决方法很简单,为 TabLayout 设置如下:

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


对于 Button 也就很简单了

android:textAllCaps="false"


阅读全文
0 0