Kise
Kise

Reputation: 2905

set text color of Appcompat action bar does not work

Basically I followed this guide about customizing the Action bar https://developer.android.com/training/basics/actionbar/styling.html

and have this style in my styles.xml

    <style name="Blue" parent="Theme.AppCompat">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">@color/light_blue</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">@color/dark_blue</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">@color/light_blue</item>

    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionMenuTextColor">@color/white</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="actionMenuTextColor">@color/white</item>
</style>

with this custom action bar to change title text to white

    <!-- ActionBar styles -->
    <style name="MyActionBar"
    parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
    <!-- Support library compatibility -->
    <item name="titleTextStyle">@style/MyActionBarTitleText</item>
    <item name="android:subtitleTextStyle">@style/MyActionBarSubtitleText</item>
</style>

<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
    parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
    <!-- The textColor property is backward compatible with the Support Library -->
    <item name="textColor">@color/white</item>
</style>

<!-- ActionBar subtitle text -->
<style name="MyActionBarSubtitleText"
    parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">10sp</item>
    <!-- The textColor property is backward compatible with the Support Library -->
    <item name="textColor">@color/white</item>
    <item name="textSize">10sp</item>
</style>

<!-- ActionBar tabs text -->
<style name="MyActionBarTabText"
    parent="@style/Widget.AppCompat.ActionBar.TabText">
    <item name="android:textColor">@color/white</item>
    <item name="textColor">@color/white</item>
    <!-- The textColor property is backward compatible with the Support Library -->
</style>

but apparently the text and icon color remains black. Am I missing something?

Upvotes: 0

Views: 1229

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199805

If you just want the text to be white, that is the default for Theme.AppCompat or, if you want a light activity, use Theme.AppCompat.Light.DarkActionBar

Upvotes: 1

Related Questions