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

后端 未结 1 550
天涯浪人
天涯浪人 2021-01-27 09:10

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 erro

相关标签:
1条回答
  • 2021-01-27 09:49

    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>
    
    0 讨论(0)
提交回复
热议问题