Style from the preferences support library can't be found

1.9k views Asked by At

I'm building an android app using xamarin.android, with minimum API of 14. I have been using Xamarin.Android.Support.v7.Preference - version 23.4.0.1 , to build a preference page for my app.

I have to specify a style for the preference page, so i have added this line in my styles.xml:

<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>

But this makes the settings page look very holo and non material, which does not fit with my app's theme.
So i found out you can use @style/PreferenceThemeOverlay.v14.Material instead which will give you the material look(Based on SO answer). This requires me to add the Xamarin.Android.Support.v14.Preference library so i added it since i support API 14+.

I tried to build the project and it can't seem to locate the PreferenceThemeOverlay.v14.Material style, here is the full error:

No resource found that matches the given name (at 'preferenceTheme' with value '@style/PreferenceThemeOverlay.v14.Material').

Here is my nuget dependencies list:

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v14.Preference" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.GridLayout" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.Preference" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.4.0.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.4.0.1" targetFramework="monoandroid70" />

How can i fix it ? Am i'm missing something? Is there a better/alternative way to achieve the material look ?

I have looked at the the source code, of the xamarin binding for the library which can be found here, and build the project my self, and i found this file at AndroidSupportComponents-master\externals\preference-v14\res\values:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    ...
    <style name="PreferenceThemeOverlay.v14.Material">
        <item name="preferenceScreenStyle">@style/Preference.PreferenceScreen.Material</item>
        <item name="preferenceFragmentCompatStyle">@style/PreferenceFragment.Material</item>
        <item name="preferenceFragmentStyle">@style/PreferenceFragment.Material</item>
        <item name="preferenceCategoryStyle">@style/Preference.Category.Material</item>
        <item name="preferenceStyle">@style/Preference.Material</item>
        <item name="preferenceInformationStyle">@style/Preference.Information.Material</item>
        <item name="checkBoxPreferenceStyle">@style/Preference.CheckBoxPreference.Material</item>
        <item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material</item>
        <item name="switchPreferenceStyle">@style/Preference.SwitchPreference.Material</item>
        <item name="dialogPreferenceStyle">@style/Preference.DialogPreference.Material</item>
        <item name="editTextPreferenceStyle">@style/Preference.DialogPreference.EditTextPreference.Material</item>
        <item name="preferenceFragmentListStyle">@style/PreferenceFragmentList.Material</item>
    </style>
     ...
</resources>

So it seems that the style is contained in the library, and should be contained with the library, maybe the build progress is wrong ? Or i'm not referencing the library properly ?

1

There are 1 answers

0
David Barishev On BEST ANSWER

Apparently, i have done everything right, and it was a caching issue with VS, i have redownload the package and restarted the PC, and the project compiled successfully.