对于项目出错检索父:没有资源的发现,给定的名称匹配“的Andr​​oid版本:Theme.Material”

对于项目出错检索父:没有资源的发现,给定的名称匹配“的Andr​​oid版本:Theme.Material”

问题描述:

我想使用材料主题与下面code

I am trying to use material Theme with following code

我的styles.xml文件

My styles.xml file

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="Android:Theme.Material">
        <item name="android:colorPrimary">@color/primary</item>

    </style>

</resources>

虽然这样做我收到以下错误:

While doing this i am getting following error :

Error retrieving parent for item: No resource found that matches the given name 'Android:Theme.Material'  

什么是错呢?

请按照下列步骤
1.首先确定你的资源新的XML文件/文件夹值名称(color.xml)。
2.然后定义您的自定义颜色。

Follow these steps 1. first of all define a new xml file in your res/values folder name(color.xml). 2. then define your custom color as.

<resources>
<color name="primary">#03f</color>
</resources>

问题是,你的主题提供了一个场所来定制,但它不知道@彩色/初级这个事情。

The problem is that your theme has provided a place to customize but it does not know @color/primary this thing.

现在再次尝试运行项目。

now try again to run the project.

记住设置安卓的minSdkVersion =L机器人:targetSdkVersion =L