Xamarin Android:资源 android:style/AppTheme.Base 未找到



我是Xamarin Android开发的新手。 我正在遵循Microsoft初始屏幕教程:https://learn.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

我收到错误,说找不到应用程序主题

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MyTheme" parent="AppTheme.Base"></style>
<style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowActionBar">true</item>
</style>

如果您查看他们链接到的页面底部的示例,您可以看到它们在其资源文件中更改了一点命名。他们还在文档后面切换名称,这有点令人困惑。https://github.com/xamarin/monodroid-samples/blob/master/SplashScreen/SplashActivity/Resources/values/style.xml

您应该能够在您显示的 XML 中简单地将AppTheme更改为AppTheme.Base,并且它应该可以工作。假设您在 AndroidManifest 的应用程序节点中使用MyTheme,在 SplashActivity 中使用MyTheme.Splash

你可以试试这个:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MyTheme" parent="AppTheme"></style>
<style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowActionBar">true</item>
</style>

然后使用@style/MyTheme