【问题标题】:Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. visual studio xamarin检索项目的父项时出错:找不到与给定名称“Theme.AppCompat.Light.DarkActionBar”匹配的资源。视觉工作室 xamarin
【发布时间】:2017-02-13 06:23:47
【问题描述】:

它给了我 9 style.xml 错误,说

检索项目的父项时出错:未找到与 给定名称“Theme.AppCompat.Light.DarkActionBar”错误无资源 找到与给定名称匹配的:attr 'windowNoTitle'。

我正在使用带有 xamarin 的 Visual Studio

    <?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
  </style>

  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.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">#a84849</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#444</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#a84849</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <!--<item name="datePickerDialogTheme">@style/AppCompatDialogStyle</item>-->
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#A84849</item>
  </style>
</resources>

【问题讨论】:

  • 稍微观察一下,您似乎正在递归地继承您的主题。 'MainTheme' 继承自 'MainTheme.Base' 而 'MainTheme.Base' 似乎继承自 'MainTheme'。

标签: android xamarin.android


【解决方案1】:

正确解决方案 > 清洁。然后重新构建。

您还可以关闭并重新打开 VS,它有助于解决那些奇怪的“未找到资源”错误。

还可以尝试添加 'android:windowNoTitle' 而不仅仅是 'windowNoTitle'

【讨论】:

    【解决方案2】:

    您不能参考 android support v7 AppCompat 库。它会显示如下错误。

    请添加支持 v7 AppCompat 库表单 nuget :

    您将获得成功:

    【讨论】:

      猜你喜欢
      • 2016-12-23
      • 1970-01-01
      • 2015-08-17
      • 2017-10-27
      • 2014-06-04
      • 2017-02-10
      • 2017-06-27
      • 2017-09-25
      • 1970-01-01
      相关资源
      最近更新 更多