简体   繁体   English

找不到与给定名称“android:Theme.Material”匹配的资源

[英]No resource found that matches the given name 'android:Theme.Material'

After reading this answer , I made RecyclerView ran it on Android 3.0+. 看完这个答案后 ,我让RecyclerView在Android 3.0+上运行了它。 But styles.xml in values-v21 still causes the error. values-v21 styles.xml中的styles.xml仍会导致错误。

Theme. 主题。

<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">

    <!-- Main theme colors -->
    <!-- your app's branding color (for the app bar) -->
    <item name="android:colorPrimary">#f00</item>
    <!-- darker variant of colorPrimary (for status bar, contextual app bars) -->
    <item name="android:colorPrimaryDark">#0f0</item>
    <!-- theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">#00f</item>
</style>

Error. 错误。

Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'. 错误:检索项目的父项时出错:找不到与给定名称“android:Theme.Material”匹配的资源。

I need to support Android versions from Android 3.0.x (API level 11). 我需要支持Android 3.0.x(API级别11)的Android版本。 <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" /> is not a solution. <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />不是解决方案。

android:Theme.Material仅支持API级别21.您可以在android studio中看到错误消息,如下所示:

android.Theme.Material requires API level 21(current min is 14)

If you use the support library, you can safely use those attributes, and they will work (as much as the OS allows) : 如果您使用支持库,您可以安全地使用这些属性,它们将起作用(尽可能多的操作系统允许):

<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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检索父项时出错:找不到与给定名称“ Android:Theme.Material”匹配的资源 - Error retrieving parent for item: No resource found that matches the given name 'Android:Theme.Material' 找不到与给定名称“android:Theme.Material.Light.DarkActionBar”匹配的资源 - No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar' 找不到与给定名称匹配的资源&#39;@android:style / Theme.Material.Light.DialogWhenLarge.NoActionBar&#39; - No resource found that matches the given name '@android:style/Theme.Material.Light.DialogWhenLarge.NoActionBar' 检索项目的父项时出错:找不到与给定名称“android:Theme.Material.Light”匹配的资源 - Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light' 找不到匹配给定名称'android:Theme.Holo.Light'的资源 - No resource found that matches the given name 'android:Theme.Holo.Light' Android:找不到与给定名称匹配的资源:Theme.AppCompat.Light - Android: No resource found that matches the given name :Theme.AppCompat.Light 找不到与给定名称&#39;@android:style / Theme.MyStyle&#39;相匹配的资源 - No resource found that matches the given name '@android:style/Theme.MyStyle' 找不到与给定名称&#39;@android:style / theme.AppCompat匹配的资源 - No resource found that matches the given name '@android:style/theme.AppCompat 错误:找不到与给定名称匹配的资源(在“主题”处,值为“ @ style / Theme.Material.Light.DarkActionBar”) - Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Material.Light.DarkActionBar') 找不到与给定名称匹配的资源(在“主题”处…) - No resource found that matches the given name (at 'theme' …)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM