How do I refer to an android resource that is in an android class library from AndroidManifest.xml?

JohnBell.2260JohnBell.2260 GBMember ✭✭
edited February 2018 in Xamarin.Android

I have an android class library that contains resources that I want to refer to from within my android application. I want to access styles, for example. Is this possible and if so, what is the syntax I need to use?

Answers

  • JohnBell.2260JohnBell.2260 GBMember ✭✭

    I should clarify, I want to access the styles from within an axml file.

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    These resources should be merged into each other in which you would generally access the same way you would in a Xamarin.Android project.

  • JohnBell.2260JohnBell.2260 GBMember ✭✭

    Sorry Jon, I don't quite follow. Can you show me an example of the syntax I would use to reference a style defined in a class library from an axml file?

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    For example,

    LibraryA
    ProjectA

    When ProjectA references LibraryA, it will "Merge" resources in the sense of combining the resources you can access within ProjectA.

    This should merge into one Resource.designer.cs file that you use to then reference the respective style in your XML. For example using the syntax found at the bottom of this doc:

    https://developer.android.com/guide/topics/resources/style-resource.html

  • JohnBell.2260JohnBell.2260 GBMember ✭✭

    Ah, so there is no need for a package prefix, it should be part of the main apps resources, so "@style/mystyle", for example, should suffice. Ok, thanks.

  • dibakarchoudhurydibakarchoudhury USMember ✭✭

    Sorry to dig this out. I have a Android Library project A which is used as a dependencdy on an Android Application project B. The Resources from A are not available on the final Resource. designer.cs

    Is this something that is supposed to work out of the box or is there somethis additional needs to be done.
    I am on VS 2019 and targeting Android 10

Sign In or Register to comment.