来自 NuGet 包的引用样式



>我有一个定义样式的NuGet包。

<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>

我把它安装在我的新项目中,我想把它用作主主题的父主题。

我尝试了许多格式(带和不带@:style/Resources.Style等(

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"
[...]

但错误总是相同的:

检索项的父项时出错:找不到与给定名称"基本主题"匹配的资源

这可行吗?如果是这样,如何?

谢谢。

在 Xamarin 论坛上提出相同的问题

@JonZarate,在这里,就像@Ramps所说的那样,你不能将 res 文件夹打包到.dll文件中(是一样的,在原生 android 中,你不能将 res 文件夹打包到.jar文件中(。

还可以在 nuget 包(.dll 文件(中添加 TextView 类的样式,并在项目的 TextView 标记中引用它以确认是否可以引用它。

Xamarin.Android.Support.V7.AppCompat
Xamarin.Android.Support.Design nuget 包安装在 xamarin.android 项目中。如果没有,请安装并关闭解决方案,删除bin和obj文件夹,然后重新打开您的解决方案。

最新更新