问题
<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>
Please try to resolve the problem.
回答1:
android:Theme.Material requires API level 21 and so it's cleared that your minSDKVersion is lower than 21.
If you really want to develop app for API 21 then declare android:minSDKVersion=21.
And if in case you want to provide compatibility to lower version then you need to use support library, which is commonly known as AppCompat library.
You can access above attributes using AppCompat:
<item name=”colorPrimary”>@color/primary</item>
<item name=”colorPrimaryDark”>@color/primary_dark</item>
回答2:
Actually, you can use this attribute, using the support library:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<item name="colorPrimary">...</item>
</style>
You can also use the others:
<item name="colorPrimaryDark">...</item>
<item name="colorAccent">...</item>
回答3:
android:colorPrimary is supported only from API level 21. You can see the error message in android studio and in eclipse below:
android:colorPrimary requires API level 21 (current min is 14)
来源:https://stackoverflow.com/questions/26881072/no-resource-found-that-matches-the-given-name-at-androidcolor-primary