简体   繁体   English

找不到与给定名称Styles.xml匹配的资源

[英]No resource found that matches the given name Styles.xml

I am trying to design a new theme for my android application in C# in Xamarin. 我正在尝试为Xamarin中的C#为我的android应用程序设计一个新主题。 I have followed a few tutorials and answers on this but I keep getting the error 我已经遵循了一些教程和答案,但我不断收到错误

No resource found that matches the given name (at 'theme' with value '@android:style/Theme.CustomActionBarTheme') 找不到与给定名称匹配的资源(在“主题”处,值为“ @android:style / Theme.CustomActionBarTheme”)

I have check a few of the relevant answer for this error but none seem to work for me :( 我已经检查了一些有关此错误的答案,但似乎没有一个对我有用:(

Heres my xml code which is located in my Values folder under Resources: Styles.xml 这是我的xml代码,位于我的Values文件夹中的Resources: Styles.xml下

<?xml version="1.0" encoding="utf-8" ?> 
<resources>
  <style 
    name="AppBaseTheme" 
    parent="android:Theme.Holo.Light">
  </style>

  <style 
    name="CustomActionBarTheme"
    parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item 
      name="android:actionBarStyle">@style/MyActionBar
    </item>
  </style>

  <style 
    name="MyActionBar"
    parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item 
      name="android:background">#033C73
    </item>
  </style>
</resources>

Can anyone help me out a bit? 谁能帮我一下吗?

Thanks 谢谢

  • EDIT * So here is the top of my MainActivity.cs 编辑*所以这是我的MainActivity.cs的顶部

     [Activity(Label = "My App", MainLauncher = true, Icon = "@drawable/icon", Theme = "@android:style/Theme.CustomerActionBarTheme")] public class MainActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); } 

Where is your theme Theme.CustomActionBarTheme ? 您的主题Theme.CustomActionBarTheme在哪里? You call it but it doesn't exist 您称之为它但不存在

Did you make changes in your manifest file 您是否在清单文件中进行过更改

<application

android:theme="@style/CustomActionBarTheme" >

 </application>

Now you must be declaring it as 现在,您必须将其声明为

android:theme="@android:style/CustomActionBarTheme" >

Change to: 改成:

[Activity(Label = "My App", MainLauncher = true, Icon = "@drawable/icon", Theme = "@style/Theme.CustomActionBarTheme")]
public class MainActivity : Activity

... ...

You have misspelled your theme name ( CustomerActionBarTheme instead of CustomActionBarTheme ) and Theme style is declared without the android: prefix 您拼错了主题名称( CustomerActionBarTheme而不是CustomActionBarTheme ),并且声明了主题样式而没有android:前缀

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到与common_signin_btn_icon_dark.xml中的给定名称匹配的资源 - No resource found that matches the given name in common_signin_btn_icon_dark.xml 没有找到与给定名称匹配的资源,我在哪里做错了? - No resource found that matches the given name, where I do something wrong? 在Xamarin.Android中找不到与给定名称匹配的资源(在&#39;headerLayout&#39;处) - No resource found that matches the given name (at 'headerLayout') in Xamarin.Android 设置Xamarin.Forms-“找不到与给定名称匹配的资源...” - Setup Xamarin.Forms - “No resource found that matches the given name…” 找不到与给定名称匹配的资源 - No resource found that matches the given names styles.xml无法正常工作 - styles.xml is not working as intended 检索项目的父项时出错:找不到与给定名称“ThemeOverlay.AppCompat.Light”匹配的资源 - Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Light' Xamarin-检索项目的父项时出错:找不到与给定名称&#39;Theme.AppCompat.Light.DarkActionBar&#39;匹配的资源 - Xamarin - Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar' 找不到与给定名称匹配的资源(在&#39;src&#39;处,值为&#39;@android:drawable / logo.png - No resource found that matches the given name (at 'src' with value '@android:drawable/logo.png 未找到与给定名称匹配的资源(值与值 @integer/google_play_services_version)”- Visual Studio 2015 更新 3 - No resource found that matches the given name (at value with value @integer/google_play_services_version)” - Visual Studio 2015 Update 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM