Action Bar Sherlock 4 title text colour - where am I going wrong?

爷,独闯天下 提交于 2019-12-30 06:21:23

问题


I'm having difficulty making my Action Bar title text colour go white. Having followed examples I believe my code is correct, however the text appears black.

Can anyone see what I am doing wrong?

<resources>
    <style name="Theme.MyApp" parent="Theme.Sherlock.Light">
        <item name="actionBarStyle">@style/Widget.MyApp.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.MyApp.ActionBar</item>
        <item name="titleTextStyle">@style/Widget.MyApp.TitleTextStyle</item>
        <item name="android:titleTextStyle">@style/Widget.MyApp.TitleTextStyle</item>
    </style>

    <style name="Widget.MyApp.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
        <item name="background">@drawable/gradient_blue</item>
        <item name="android:background">@drawable/gradient_blue</item>
    </style>

    <style name="Widget.MyApp.TitleTextStyle" parent="Widget.Sherlock.Light.ActionBar">
        <item name="titleTextStyle">@color/white</item>
        <item name="android:titleTextStyle">@color/white</item>
    </style>
</resources>

Many thanks in advance!


回答1:


Use the following, just customize the actionBarStyle property:

<resources>
    <style name="Theme.MyApp" parent="Theme.Sherlock.Light">
        <item name="actionBarStyle">@style/Widget.MyApp.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.MyApp.ActionBar</item>
    </style>

    <style name="Widget.MyApp.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
        <item name="titleTextStyle">@style/Widget.MyApp.TitleTextStyle</item>
        <item name="android:titleTextStyle">@style/Widget.MyApp.TitleTextStyle</item>
    </style>

    <style name="Widget.MyApp.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
        <item name="android:textColor">@color/white</item>
    </style>
</resources>

and you can customize textSize of title too.




回答2:


You should set the text color and other text property's within the text style.

<style name="Widget.MyApp.TitleTextStyle" parent="Widget.Sherlock.Light.ActionBar">
    <item name="android:textColor">@color/white</item>
</style>


来源:https://stackoverflow.com/questions/10466796/action-bar-sherlock-4-title-text-colour-where-am-i-going-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!