Bikash
Bikash

Reputation: 477

No resource found that mach the given name Theme.AppCompat.Light.NoActionBar

I am adding some items in Styles.xml files. However, it is giving me an error.

Here is my code.

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#2196F3</item>
        <item name="drawerArrowStyle">@style/MyDrawerArrowStyle</item>
    </style>
    <style name="MyDrawerArrowStyle"   parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="color">#F5F5F5</item>
        <item name="spinBars">true</item>
    </style>
</resources>

Error can be seen in the screenshot below

error screenshot

  1. Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.
  2. No resource found that matches the given name: attr 'colorPrimary'.
  3. No resource found that matches the given name: attr 'drawerArrowStyle'. 4..No resource found that matches the given name 'Widget.AppCompat.DrawerArrowToggle'.
  4. No resource found that matches the given name: attr 'color'.
  5. No resource found that matches the given name: attr 'spinBars'.

Upvotes: 16

Views: 14834

Answers (4)

Waqas Munawer
Waqas Munawer

Reputation: 11

Here are the steps to fix those issues;

  1. Go to AndroidManifest.xml and add android:targetSdkVersion to 23 under uses-sdk tag.
  2. Go to Project -> General and set Target framework to Android 6.0 (Marshmallow).
  3. Go to Project -> Android Application -> set Target Android version to Android 6.0.

Android version 7.0 is not compiled in latest Xamarin Studio.Right now you can only compile Android project up to Android 6.0.

Upvotes: 1

james kandau
james kandau

Reputation: 129

add component Support Library v7 AppCompat 

create values/styles and add
<?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="MyTheme" parent="MyTheme.Base">
  </style>
  <style name="MyTheme.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">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
  </style>
</resources>

add another folder values-v21
create styles.xml and add
<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <!--
        Base application theme for API 21+. This theme replaces
        MyTheme from resources/values/styles.xml on API 21+ devices.
    -->
  <style name="MyTheme" parent="MyTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
  </style>
</resources>

Upvotes: 1

Bikash
Bikash

Reputation: 477

I found my solution by adding AppCompact v7 in the Package of my xamarin studio android project.

Link= https://components.xamarin.com/view/xamandroidsupportv7appcompat

Upvotes: 15

Cheesebaron
Cheesebaron

Reputation: 24460

I can't remember if Theme.AppCompat.Light.NoActionBar exists in the first place.

You could do something like this instead:

<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">#2196F3</item>
    <item name="drawerArrowStyle">@style/MyDrawerArrowStyle</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

Upvotes: 2

Related Questions