Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Cant style preference screen

DavidBarishevDavidBarishev USMember ✭✭
edited October 2016 in Xamarin.Android

I'm building an android app using, with minimum API of 14.
I have been using Xamarin.Android.Support.v7.Preference - version , 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="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v14.Preference" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.GridLayout" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.Preference" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="" 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"?>
    <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>

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 ?

Sign In or Register to comment.