ChristianCuevas
ChristianCuevas

Reputation: 2692

No resource found that matches the given name: attr 'colorPrimary'

I am trying to change the color of my action bar in android studio. I have already changed the minSDKVersion to 21 so I know that is not the problem. Yet I keep getting the error, I don't know what is going on. Here is my xml:

<!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Material">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/my_action_bar_color</item>
    <item name="android:navigationBarColor">@color/my_action_bar_color</item>
</style>

No resource found that matches the given name: attr 'colorPrimary'.

Upvotes: 0

Views: 7565

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006574

Use android:colorPrimary. colorPrimary on its own will only work if you are inheriting from Theme.AppCompat.

So, for example, in this sample project, I have:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Apptheme" parent="android:Theme.Material">
    <item name="android:colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <item name="android:colorAccent">@color/accent</item>
  </style>
</resources>

Upvotes: 7

Related Questions