5
votes

I'm learning Material Design, in particular I want to customize my app with Material Design also for the older Android versions. I'm reading this guide: https://developer.android.com/training/material/compatibility.html#SupportLib

About Color Palette, the guide says:

To obtain material design styles and customize the color palette with the Android v7 Support Library, apply one of the Theme.AppCompat themes:

<!-- extend one of the Theme.AppCompat themes -->
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- customize the color palette -->
    <item name="colorPrimary">@color/material_blue_500</item>
    <item name="colorPrimaryDark">@color/material_blue_700</item>
    <item name="colorAccent">@color/material_green_A200</item>
</style>

When I try to run this code, I got this error:

error: Error: No resource found that matches the given name: attr 'colorAccent'.

...and the same error for colorPrimaryDark and colorPrimary! If I run this code into the values-v21/style.xml file, putting the " android: " tag before colorPrimary, colorPrimaryDark and colorAccent, as:

<item name="android:colorPrimary">@color/material_blue_500</item>
<item name="android:colorPrimaryDark">@color/material_blue_700</item>
<item name="android:colorAccent">@color/material_green_A200</item>

it works!

So...I don't understand where I'm wrong :( I've surely updated the v7 support library

Any help will be appreciated! :)

1
Have you import the library and compile it with your project? Also make sure you run Rebuild Project if you are using Android Studio.Anggrayudi H
I got this problem fixed by setting targetSdkVersion to 21 in my gradle build file, and changing compile 'com.android.support:appcompat-v7:20.+' to use 21.+. I don't understand it though, so I don't know if it will work for you. Then you'll run into the problem of stackoverflow.com/questions/3963978/…LarsH

1 Answers

-3
votes

Try

parent="android:Theme.AppCompat.Light"

Might also reference:

No resource found - Theme.AppCompat.Light.DarkActionBar