Forum Xamarin Xamarin.Android

Referencing resources from Android class library in XML

I'm looking at moving some common resources into an Android class library project which is then referenced by the actual application projects but I'm having difficulty figuring out how to refer to those shared resources in XML. I can see from the Android/Xamarin documentation the syntax is [PackageName:]ResourceType/ResourceName but I'm not sure what the "PackageName" should be for class libraries - I thought it might be the namespace of the class library but that doesn't work. I've spent some time researching the issue but haven't been able to find any solutions to this so any pointers would be much appreciated.

So for example, I have a class library "AndroidSharedLibrary" with the same namespace. Within the resources folder I have values\colors.xml with a colour of "shared_test". In my application project's styles.xml I attempt to reference it as:

item name="android:windowBackground">@AndroidSharedLibrary:color/shared_test

Which produces the error

error APT0000: No resource found that matches the given name (at 'android:windowBackground' with value '@androidsharedlibrary:color/shared_test').

My application project does have a reference to the class library project and I can use classes defined in there OK, it's just the resources which are causing me a problem.



Sign In or Register to comment.