簡體   English   中英

Xamarin Android:資源android:找不到樣式/AppTheme.Base

[英]Xamarin Android: Resource android: style/AppTheme.Base Not Found

我是 Xamarin Android 開發的新手。 我正在關注 Microsoft 啟動畫面教程: https : //docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

我收到錯誤提示 The AppTheme.Base not found

<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更改為AppTheme.Base並且它應該可以工作。 鑒於您在 AndroidManifest 的 Application 節點中使用MyTheme ,在MyTheme.Splash中使用 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM