没有资源的发现,匹配给定的名字:ATTR“colorPrimary” [英] No resource found that matches the given name: attr 'colorPrimary'

查看:5258
本文介绍了没有资源的发现,匹配给定的名字:ATTR“colorPrimary”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变我的操作栏的颜色机器人工作室。我已经改变了的minSdkVersion为21,所以我知道这是没有问题的。然而,我不断收到错误,我不知道是怎么回事。这里是我的xml:

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>

没有资源的发现,匹配给定的名字:ATTRcolorPrimary

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

推荐答案

使用安卓colorPrimary colorPrimary 自己才会如果你是从 Theme.AppCompat 继承工作。

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>

这篇关于没有资源的发现,匹配给定的名字:ATTR“colorPrimary”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆