【发布时间】:2015-10-12 16:54:14
【问题描述】:
设置
我对 Xamarin 很陌生,我正在尝试遵循官方文档并在虚拟应用中实现 Lollipop Material Design Style。
我已经添加了该 repo 中出现的资源:
(事实证明,values-v21 是正确的文件夹名称,与 repo 上的不同)
然后我还从 SDK 管理器安装了整个 Android API 21 文件夹,还安装了 NuGet Xamarin.Android.Support.v7.AppCompat,它在我的 packages.config AFAIK 中正确显示:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Android.Support.v4" version="23.0.1.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.0.1.1" targetFramework="MonoAndroid50" />
</packages>
错误
但是当我点击播放(以 API 21 作为目标的调试模式)时,我收到以下三个错误:
Build FAILED.
Errors:
/Users/pegasus/Projects/DistraeMe/DistraeMe/DistraeMe.csproj (Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_UpdateAndroidResgen target) ->
Resources/values-v21/styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'CardView'.
Resources/values-v21/styles.xml(2): error APT0000: No resource found that matches the given name: attr 'cardBackgroundColor'.
Resources/values-v21/styles.xml(2): error APT0000: No resource found that matches the given name: attr 'cardCornerRadius'.
这是从 repo 中粘贴的 styles.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<!-- Define a custom theme that derives from the light Material Theme -->
<style name="MyCustomTheme" parent="android:Theme.Material.Light">
<!-- Override the app bar color -->
<item name="android:colorPrimary">@color/my_blue</item>
<!-- Override the color of UI controls -->
<item name="android:colorAccent">@color/my_purple</item>
</style>
<!-- Theme an individual view: -->
<style name="CardView.MyBlue">
<!-- Change the background color to Xamarin blue: -->
<item name="cardBackgroundColor">@color/my_blue</item>
<!-- Make the corners very round: -->
<item name="cardCornerRadius">18dp</item>
</style>
</resources>
我没有正确链接这些资源吗?我做错了什么?
【问题讨论】:
标签: android xamarin xamarin.forms xamarin-studio