I have an android application built with Xamarin Studio. I added a file named colors.xml to the Resources/values folder. The contents were:
<resources>
<color name="ViewBackgroundColor">#ffffff</color>
</resources>
To that, I was following this approach to define and use it; however, I was trying to apply it to the view's root element (found that resource elsewhere on SO, don't have exact link). So I applied it to the view by adding android:background="@color/ViewBackgroundColor"
attribute to the root element. However, this generates a build error that @color/ViewBackgroundColor isn't a value. is anybody else having this issue and is there a resolution?
To reference that color, you must use all lowercase letters.
So
android:background="@color/viewbackgroundcolor"
This is because the Xamarin tools lowercases all names to be compliant with the rules Android has for resource names.
Is also important to set "Build Action" (with mouse right button on file color.xml) as AndroidResource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With