Search code examples
androidpreferencefragment

PreferenceFragment has holo design in Android 6.0


My phone is Android 6.0 but preferencefragment has mixed design with holo and material design. I want to change its design to perfect material design. But i can't change it.

My PreferenceFragment java code. I used android.support.v7.preference.PreferenceFragmentCompat

public class AboutFragment extends PreferenceFragmentCompat {

@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.pref_about_general);
}

Solution

  • Can you try to add this lib in your build.gradle :

    compile 'com.android.support:preference-v14:24.2.1'
    

    EDIT:

    Add this in your style.xml file :

    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
            //below your own item            
            ...
            <item name="preferenceTheme">@style/PreferenceTheme</item>
    
    </style>
    

    And define your PreferenceTheme :

    <style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
            <item name="colorAccent">@color/colorid</item>
            <item name="android:textColorPrimary">@color/colorid</item>
            <item name="android:textColorSecondary">@color/colorid</item>
        </style>
    

    But in your code you use the v7 version, the v14 is just for material design support.

    Hope this helps.