【问题标题】:Xamarin Android: Resource android: style/AppTheme.Base Not FoundXamarin Android:资源 android:样式/AppTheme.Base 未找到
【发布时间】:2020-02-09 03:32:38
【问题描述】:

我是 Xamarin Android 开发的新手。 我正在关注 Microsoft Splash Screen 教程:https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

我收到错误提示找不到 AppTheme.Base

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

【问题讨论】:

  • 可以吗?

标签: c# android visual-studio xamarin


【解决方案1】:

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

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

【讨论】:

  • 我尝试使用 AppTheme.Base 并且 Visual Studio 不断抛出 AppThem.Base not found。
【解决方案2】:

你可以试试这个:

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

【讨论】:

    猜你喜欢
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 2013-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多