简体   繁体   English

如何更改 ActionBar Tab 的 textStyle?

[英]How to change ActionBar Tab textStyle?

By default android actionBar Tab has text-style as CAPITAL.默认情况下,android actionBar Tab 的文本样式为 CAPITAL。 How can I set the text-style to normal camel-case style.如何将文本样式设置为普通的驼峰式样式。 Like "Abcd" instead of "ABCD"(Which is the by-default style)像“Abcd”而不是“ABCD”(这是默认样式)

To make the tab text lowercase, create a style that inherits Widget.Holo.Light.ActionBar.TabText Widget.Holo.ActionBar.TabText and set android:textAllCaps to false .为了使标签文本小写,创建一个样式继承Widget.Holo.Light.ActionBar.TabText Widget.Holo.ActionBar.TabText和集android:textAllCapsfalse

You can apply your own ActionBar.Tab text style by using the android:actionBarTabTextStyle attribute.您可以使用android:actionBarTabTextStyle属性应用您自己的ActionBar.Tab文本样式。

For AppCompat compatibility, your style should inherit Widget.AppCompat.Light.ActionBar.TabText or Widget.AppCompat.ActionBar.TabText and the attributes are the same as above, minus the android prefix.为了与AppCompat兼容,你的样式应该继承Widget.AppCompat.Light.ActionBar.TabTextWidget.AppCompat.ActionBar.TabText并且属性与上面相同,减去android前缀。

For more information, you should read: Styling the ActionBar有关更多信息,您应该阅读: 设置 ActionBar 的样式

Here's an example with AppCompat compatibility:以下是与AppCompat兼容的示例:

values价值观

<style name="Your.Theme" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarTabTextStyle">@style/Your.TabText.Style</item>
    <item name="actionBarTabTextStyle">@style/Your.TabText.Style</item>
</style>

<style name="Your.TabText.Style" parent="@style/Widget.AppCompat.Light.ActionBar.TabText">
    <item name="textAllCaps">false</item>
</style>

values-v14值-v14

<style name="Your.TabText.Style" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
    <item name="android:textAllCaps">false</item>
</style>

Results结果

例子

Apply custom theme to your app where you can change actionbar's properties.将自定义主题应用于您的应用程序,您可以在其中更改操作栏的属性。

<style name="Theme.MyAppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
    <item name="android:textAllCaps">false</item>
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM