Xamarin颜色导致构建错误

Bri*_*ins 5 android styles xamarin.android xamarin

我有一个用Xamarin Studio构建的android应用程序.我在Resources/values文件夹中添加了一个名为colors.xml的文件.内容如下:

<resources>
    <color name="ViewBackgroundColor">#ffffff</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

为此,我遵循这种方法来定义和使用它; 但是,我试图将它应用于视图的根元素(发现SO上其他地方的资源,没有确切的链接).所以我通过向android:background="@color/ViewBackgroundColor"根元素添加属性将它应用于视图.但是,这会生成@ color/ViewBackgroundColor不是值的构建错误.有没有其他人有这个问题,有解决方案吗?

Che*_*ron 8

要引用该颜色,必须使用全部小写字母.

所以

android:background="@color/viewbackgroundcolor"
Run Code Online (Sandbox Code Playgroud)

这是因为Xamarin工具将所有名称缩小为符合Android对资源名称的规则.