6

I'm following the android development tutorials from developers.android.com, and currently I'm trying to style my action bar using the information given here: https://developer.android.com/training/basics/actionbar/styling.html#CustomBackground7

Here's the code of res/values/themes.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>

    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>

    </style>
</resources>

I see red cross icons beside the "style" opening tags, hovering on which the error message reads: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'.

  • My application has minSdkVersion="11" and targetSdkVersion="21", I tried changing the minSdkVersion to 13, 14 but it made no difference
  • Someone suggested to check whether appcompat has been marked as library project or not, I checked it and the "isLibrary" option was checked in the appcompat properties window.
  • I also made sure that appcompat was added to my project as a library project.
  • removing "@android" from "@android:style" or removing the "@" doesn't work. However in the first style tag, when I remove "@android" then the red cross sign goes away, but that doesn't happen for the second style tag.

Please help. I've been at it since morning and I'm not getting anywhere.

3
  • 1
    The Theme.AppCompat styles are not under the android sdk so you use parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse".
    – user
    Oct 18, 2014 at 7:32
  • Are you using Android Studio?? Oct 18, 2014 at 7:36
  • @Lucksprog, Thank you so much! That worked! goonerdroid, I'm using eclipse. Oct 18, 2014 at 7:40

1 Answer 1

10

Try to delete android:, like this:

<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light.DarkActionBar">
1
  • Brilliant, this worked for me. I didn't even have the "@" and it worked.
    – Prof
    Jun 6, 2016 at 13:48

Your Answer

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

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