1

This is my first project working with Android (Xamarin) and i was trying to style the ActionBar. I succesfully changed the background color, but now the text within it is either gone or the same color as the background. I think the second because i only changed the background. Below is my Styles.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="hme" parent="android:Theme.Material">
        <item name="android:actionBarStyle">@style/hme.ActionBar</item>

        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/hme.ActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="hme.ActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
        <item name="android:background">@color/primary</item>
        <item name="android:titleTextStyle">@style/hme.ActionBar.Text</item>

        <!-- Support library compatibility -->
        <item name="background">@color/primary</item>
    </style>

    <style name="hme.ActionBar.Text" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/white</item>
    </style>

    <style name="hme.Splash" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

And here is a screenshot on Gyazo of how it looks. (Not enough rep to post a picture): http://gyazo.com/161cd58ced1f7a147b29f8ee6aa401af

I checked other fixes on SO on diffent questions but nothing seems to work, can anybody help me?

1
  • If i change "@color/primary" to "@color/black", both the text and the actionbar is black
    – dylanvdb
    Apr 28, 2015 at 18:58

1 Answer 1

0

You can add

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

into your hme style:

<style name="hme" parent="android:Theme.Material">
    <item name="android:actionBarStyle">@style/hme.ActionBar</item>
    <item name="android:textColorPrimary">@android:color/black</item>
    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/hme.ActionBar</item>
</style>

Check also:

<item name="android:textColor">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/black</item>

may be useful.

3
  • Thanks for the reply! But this isn't working, i added the lines you provided and the actionbar is still like the screenshot i provided.
    – dylanvdb
    Apr 28, 2015 at 18:55
  • @Dylan2308 Replace @style/Widget.AppCompat.ActionBar.Solid with android:Widget.Material.ActionBar.Solid. I tested it, and it's works
    – RediOne1
    Apr 28, 2015 at 20:16
  • Sorry for the late reply but thanks! It's working now
    – dylanvdb
    May 20, 2015 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.