Search code examples
androidxmlandroid-studioandroid-themecyanogenmod

Unable to reference a color attribute in a drawable


I'm trying to create a custom set of colors, to further reference them throughout a theme.

I found a similar post here and by following those steps, I'm trying to define holo_blue_dark as the custom color:

res\values\attrs.xml

<attr name="holo_blue_dark" format="reference|color" />

res\values\styles.xml

<style name="AppTheme.Dark" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="holo_blue_dark">@color/red</item>
</style>

res\values\colors.xml

<color name="holo_blue_dark">#FF33B5E5</color>

I always get Failure [INSTALL_FAILED_THEME_AAPT_ERROR] in Android Studio 0.8.2, so I must be missing something.


Solution

  • res\values\attrs.xml

    <attr name="holo_blue_dark" format="color"/>
    

    res\values\styles.xml

    <style name="AppTheme.Dark" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="holo_blue_dark">@color/your_color</item>
    </style>
    

    res\values\colors.xml

    <color name="your_color">#FF33B5E5</color>
    

    And make sure you are using the theme AppTheme.Dark where you are using that attribute.