找不到与给定名称匹配的资源(在' android:colorPrimary'有值' @android:colors / blue')。 2

时间:2017-07-13 13:35:47

标签: android xamarin

在我的Colors.xml中,我声明蓝色如下

#375D81

这是我Styles.xml

的链接

3 个答案:

答案 0 :(得分:0)

尝试在colors.xml中定义此颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    ...
<color name="myBlue">#375D81</color>
</resources>

并在styles.xml中引用它:

<item name="...">@color/myBlue</item>

答案 1 :(得分:0)

它显示了这个找不到与给定名称相匹配的资源(在'android:colorPrimary'中,值为''orroid:colors / blue')。错误,因为没有匹配的资源{ {1}}

您需要在res / values / color.xml中创建一个颜色资源,如下所示

@android:colors/blue

比你在主题

中的res / values / style.xml中使用这种颜色
<?xml version="1.0" encoding="utf-8"?>
<resources>
   // your all colors
    <color name="myBlue">#ff00ff</color>
</resources>

如果有任何疑问,请询问我

答案 2 :(得分:0)

在Xamarin处理.xml或.axml文件时,我们每次都需要清理和重建解决方案,因为Android每次都会检查控件的资源ID。

 <?xml version="1.0" encoding="utf-8" ?>
 <resources>
  <style name="button_text" >
  <item name="android:layout_width" >fill_parent</item>
  <item name="android:layout_height" >wrap_content</item>
  <item name="android:textColor" >#ffffff</item>
  <item name="android:gravity" >center</item>
  <item name="android:layout_margin" >3dp</item>
  <item name="android:textSize" >30dp</item>
  <item name="android:textStyle" >bold</item>
  <item name="android:shadowColor" >#000000</item>
  <item name="android:shadowDx" >1</item>
  <item name="android:shadowDy" >1</item>
  <item name="android:shadowRadius" >2</item>
</style>

https://developer.xamarin.com/recipes/android/resources/general/style_a_button/