[英]Xamarin Android Support Library custom Styles
I have an Android Application (Xamarin/Visual Studio) with the Minimum Android Version: 2.3 (API Level 10 - Gingerbread)
and Compile Android Version: 6.0 (Marshmallow)
. 我有一个Android应用程序(Xamarin / Visual Studio),其Minimum Android Version: 2.3 (API Level 10 - Gingerbread)
和Compile Android Version: 6.0 (Marshmallow)
。
I try to support all these Android Versions while keeping the Material Design Look of my App. 我尝试支持所有这些Android版本,同时保持我的应用程序的Material Design外观。
I tried using the Support Libraries (from NuGet: Xamarin.Android.Support.v7.AppCompat
version 23
, and Xamarin.Android.Support.v7.CardView
version 23
), and added them to my Project. 我尝试使用支持库(来自NuGet: Xamarin.Android.Support.v7.AppCompat
版本23
和Xamarin.Android.Support.v7.CardView
版本23
),并将它们添加到我的项目中。
Now, I created 3 custom styles for CardViews; 现在,我为CardViews创建了3种自定义样式。 in my Resources/values/styles.xml, I have the following Code: 在我的Resources / values / styles.xml中,我具有以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!--A single normal lesson for the Timegrid-->
<style name="Xamarin.Android.Support.v7.CardView.Lesson">
<item name="cardBackgroundColor">@color/orange_500</item>
<item name="cardCornerRadius">18dp</item>
</style>
<!--A single newly added lesson for the Timegrid-->
<style name="Xamarin.Android.Support.v7.CardView.LessonNew">
<item name="cardBackgroundColor">@color/green_500</item>
<item name="cardCornerRadius">18dp</item>
</style>
<!--A single cancelled lesson for the Timegrid-->
<style name="Xamarin.Android.Support.v7.CardView.LessonCancellation">
<item name="cardBackgroundColor">@color/grey_500</item>
<item name="cardCornerRadius">18dp</item>
</style>
</resources>
I cannot compile, because of the following Error: 由于出现以下错误,我无法编译:
Severity Code Description Project File Line Suppression State Error Error retrieving parent for item: No resource found that matches the given name 'Xamarin.Android.Support.v7.CardView'.
How can I fix this? 我怎样才能解决这个问题? Thanks in advance 提前致谢
Set the style parent to CardView
and change your Name
to a non-dot-qualified (local) name. 将样式父项设置为CardView
然后将“ Name
更改为非点限定(本地)名称。
<style name="LessonNew" parent="CardView">
<item name="android:layout_margin">10dp</item>
<item name="cardCornerRadius">18dp</item>
<item name="cardElevation">10dp</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.