1

I have a NuGet package where a style was defined.

<resources>

  <style name="BaseTheme" parent="Theme.AppCompat.Light">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    [...]

  </style>

  [...]

</resources>

I installed it in my new project and I want to use it as a parent for the main theme.

I tried many formattings (with and without @, :style/, Resources.Style etc.)

style name="AppTheme" parent="BaseTheme"
style name="AppTheme" parent="@style/BaseTheme"
style name="AppTheme" parent="@PACKAGE:style/BaseTheme"
style name="AppTheme" parent="PACKAGE:style/BaseTheme"
[...]

But the error is always the same:

Error retrieving parent for item: No resource found that matches the given name 'BaseTheme'

Is this doable ? If so, how ?

Thanks.

Same question on Xamarin Forums

JonZarate
  • 841
  • 6
  • 28
  • you want to get a style from a nuget package basically? – FreakyAli Apr 16 '18 at 11:55
  • I want to use it as a `parent` in a `style`, yes. – JonZarate Apr 16 '18 at 12:02
  • did you try to get it in code? if yes is it useable – FreakyAli Apr 16 '18 at 12:14
  • I can reference it in code (`.Resouce.Style. – JonZarate Apr 16 '18 at 12:24
  • Please show your NuGet package style and which folder it is, and how did you add it in your application. I guess maybe it is in the wrong folder like value-21? Or try to delete the bin and obj folder and restart your VS. – Robbit Apr 17 '18 at 09:21
  • @JoeLv-MSFT I added the style to the post. The folder is `values`, the file `styles.xml`. Restarting, cleaning, rebuilding etc already tried. – JonZarate Apr 17 '18 at 09:40

2 Answers2

2

@JonZarate, here, like @Ramps has said, you can't package the res folder into .dll file(it is the same, in native android, you can't package the res folder into .jar file).

You can also add a style for the TextView class in your nuget package(.dll file), and reference it in your project's TextView tag to confirm whether it can be referenced.

Robbit
  • 4,300
  • 1
  • 13
  • 29
-1

Is Xamarin.Android.Support.V7.AppCompat and
Xamarin.Android.Support.Design nuget package is install in your xamarin.android project. If not then kindly install and close solution delete bin and obj folder and reopen your solution.

Naveen Tiwari
  • 301
  • 2
  • 12