Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Implementing Designs for Android Customizing the Action Bar Customizing Action Bar Buttons

Roberto Palomar
Roberto Palomar
3,200 Points

ActionBar title text color

I have written the styles for the action bar as described in the video. Still, the title color remains black. Im using android studio and my theme is a child of Theme.AppCompat.Light.

<style name="Theme.Ribbit" parent="@style/Theme.AppCompat.Light"> <item name="actionBarItemBackground">@drawable/selectable_background_ribbit</item> <item name="popupMenuStyle">@style/PopupMenu.Ribbit</item> <item name="dropDownListViewStyle">@style/DropDownListView.Ribbit</item> <item name="actionBarTabStyle">@style/ActionBarTabStyle.Ribbit</item> <item name="actionDropDownStyle">@style/DropDownNav.Ribbit</item> <item name="actionBarStyle">@style/ActionBar.Solid.Ribbit</item> <item name="actionModeBackground">@drawable/cab_background_top_ribbit</item> <item name="actionModeSplitBackground">@drawable/cab_background_bottom_ribbit</item> <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Ribbit</item> <item name="android:editTextBackground">@drawable/apptheme_edit_text_holo_light</item> <item name="android:actionOverflowButtonStyle">@style/Theme.Ribbit.Overflow</item>

</style>

<style name="ActionBar.Solid.Ribbit" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_ribbit</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_ribbit</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_ribbit</item>
    <item name="progressBarStyle">@style/ProgressBar.Ribbit</item>
    <item name="android:titleTextStyle">@style/ActionBar.Solid.Ribbit.TitleTextStyle</item>
</style>

<style name="ActionBar.Solid.Ribbit.TitleTextStyle"
    parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/text_color</item>
</style>

3 Answers

Harry James
Harry James
14,780 Points

Hey Roberto!

Your ActionBar.Solid.Ribbit.TitleTextStyle style should have the parent of @style/TextAppearance.Holo.Widget.ActionBar.Title as declared in the Android Documentation here.

This should then update the text color for you.


Hopefully this will fix the problem but if you're still having problems, give me a shout and I'll be happy to help out :)

i have the same issue as well, my text does not appear to change in color.

<resources> <!-- <style name="AppTheme" parent="Theme.AppCompat.Light"> </style> -->

<style name="Theme.Snapper" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionOverflowButtonStyle">@style/Theme.Snapper.Overflow</item>
    <item name="actionBarItemBackground">@drawable/selectable_background_snapper</item>
    <item name="popupMenuStyle">@style/PopupMenu.Snapper</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Snapper</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Snapper</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Snapper</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Snapper</item>
    <item name="actionModeBackground">@drawable/cab_background_top_snapper</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_snapper</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Snapper</item>
</style>

<style name="Theme.Snapper.Overflow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
    <item name = "android:src">@drawable/ic_menu_overflow</item>
</style>

<style name="ActionBar.Solid.Snapper" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_snapper</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_snapper</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_snapper</item>
    <item name="progressBarStyle">@style/ProgressBar.Snapper</item>
    <item name="android:titleTextStyle">@style/ActionBar.Solid.Snapper.TitleTextStyle</item>

</style>

<style name="ActionBar.Solid.Snapper.TitleTextStyle"
       parent ="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/text_color</item>

</style>

like the others, i have changed the theme to AppCompat because i am using android studio. The only issue i can really see are the rendering problems in my drawable files that i have included from the android asset site. "Couldn't resolve resource @drawable/spinner_ab_disabled_snapper <item> tag requires a 'drawable' attribute or child tag defining a drawable"

<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/spinner_ab_disabled_snapper" /> <item android:state_pressed="true" android:drawable="@drawable/spinner_ab_pressed_snapper" /> <item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/spinner_ab_focused_snapper" /> <item android:drawable="@drawable/spinner_ab_default_snapper" /> </selector>

but i dont know if these correlate to the issue why my text isnt changing. Thanks

Harry James
Harry James
14,780 Points

Hey Ben Lee!

Would you be willing to share your project files across so that I can take a look for you? I'm not able to solve this just from code as it looks to be something to do with the way it is built that's causing the issue. It is fine to submit all of the code safely but please hide the keys used for Parse:

        Parse.initialize(this, 
                "SECRETKEY", 
                "SECRETKEY");

I will use my own keys for testing.

Note that if you are working on this as a private project then you probably wouldn't want to share your files since they'd be accessible to anyone.

If you are fine with this then please just post a link to the files using a cloud storage service. I'll then download your project and see if I can reproduce and solve the issues you're having.


Here's instructions on how you can export your project:

To export your project, right-click on your project in Android Studio and press Show in Explorer. Then, upload your project directory into a service like Google Drive, SkyDrive or another service of your choice.


Thanks in advance!

Carl Lippert
Carl Lippert
7,359 Points

I have the same problem Roberto. Your suggestion although technically correct Harry is most likely not the solution that will help.

If I am guessing correctly, Roberto changed out all you "Holo's" for "AppCompat" to get the last vid (or before that) to work with Android Studio and some compatibility issues. I did the same. I am just going to chalk this one up to compatibility issues and consider the true content matter understood. Until it crashes. Than maybe I'll fix it ;)

Harry James
Harry James
14,780 Points

Interesting. I'm using Android Studio and I am using the Holo's completely fine :s

If you want me to look into it then feel free to leave your project files here and I'll get back to you.

Nasir Mahamoud
Nasir Mahamoud
22,892 Points

It looks like there are two solutions to this problem using the AppCompat Theme. The first solution I found is to change the action bar text color programmatically (using code) in the Main, Recipients, and View Image Activities. This solution just requires a single line of code in each Activity's onCreate() method, which would look like:

getSupportActionBar().setTitle(Html.fromHtml("<font color='#250054'>Snapper (or Ribbit)</font>"));

The second solution I found is to add an "android:textColorPrimary" tag to your Snapper (or Ribbit) Theme, this solution would look like:

<style name="Theme.Snapper (or Ribbit)" parent="@style/Theme.AppCompat.Light">

        //....Skipped all the other tags//

        <item name="android:textColorPrimary">@color/text_color</item> 

    </style>

You can use one or the other. I chose the first solution because the second solution also changes text color in some unwanted places.