A resource was not found that matches the specified name attr "colorPrimary"

I find it difficult to compile an Android application in Xamarin Studio. The error that occurs is as follows:

A resource was not found that matches the specified name attr "colorPrimary"

What applies to my styles.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <!--item name="colorPrimaryDark">@color/colorPrimaryDark</item-->
        <!--item name="colorAccent">@color/colorAccent</item-->
    </style>
</resources>

The usual tips found on the Internet are to install the SDK version to 21 or higher. But I already tried this:

  • Set minSdkVersion to 21 in the manifest
  • Set targetSdkVersion to 21 in the manifest
  • Set tag structure for Android 5.0 in project settings
  • Cleaned and restored project

The error still exists :-( Are there any other settings necessary to complete this work?

+10
6

, .

res/values-v21/styles.xml,

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="AppTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
    <item name="android:colorPrimary">@color/primaryColor</item>
    </style>
</resources>

res/values/styles.xml,

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/primaryColor</item>
    </style>
</resources>
+11

(https://developer.android.com/training/material/theme.html#ColorPalette):

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">@color/accent</item>
  </style>
</resources>

android: colorPrimary. - , .

android:

parent="@android:style/Theme.Material.Light.DarkActionBar"
+5

, , styles.xml, . , , .

0

SDK , :

  • SDK value.xml
  • android: AndroidManifest.xml

, , , SDK ( , ...)

0

, , colorPrimary Primary ... .

, :

<style name="_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="colorPrimary">#6c0e54</item>

, xml , :

<?xml version="1.0" encoding="utf-8"?>
   <resources>
     <color name="apptheme_color1">#9D3F86</color>
     <color name="apptheme_color2">#84226C</color>
  </resources>

:

 <style name="_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="colorPrimary">@color/apptheme_color1</item>
-2

res\values\colors.xml

<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>

.

-2

Source: https://habr.com/ru/post/1651535/


All Articles