我在Styles.xml文件中添加了一些项目。但是,它给了我一个错误。
这是我的代码。
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="drawerArrowStyle">@style/MyDrawerArrowStyle</item>
</style>
<style name="MyDrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">#F5F5F5</item>
<item name="spinBars">true</item>
</style>
</resources>
错误可以在下面的截图中看到
答案 0 :(得分:14)
我通过在我的xamarin工作室android项目的包中添加AppCompact v7找到了我的解决方案。
Link = https://components.xamarin.com/view/xamandroidsupportv7appcompat
答案 1 :(得分:1)
我不记得首先是否存在Theme.AppCompat.Light.NoActionBar
。
你可以这样做:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#2196F3</item>
<item name="drawerArrowStyle">@style/MyDrawerArrowStyle</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
答案 2 :(得分:1)
以下是解决这些问题的步骤;
Android版7.0不是在最新的Xamarin Studio中编译的。现在你只能将Android项目编译到Android 6.0。
答案 3 :(得分:0)
add component Support Library v7 AppCompat
create values/styles and add
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
</style>
</resources>
add another folder values-v21
create styles.xml and add
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--
Base application theme for API 21+. This theme replaces
MyTheme from resources/values/styles.xml on API 21+ devices.
-->
<style name="MyTheme" parent="MyTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>