Is there a way to style PreferenceFragmentCompat

The title says it all: how can I create a PreferenceFragmentCompat style. My v14 / style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:editTextStyle">@style/Widget.EditText.White</item>
        <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
    </style>

    <style name="Widget.EditText.White" parent="@android:style/Widget.EditText">
        <item name="android:textColor">#ffffffff</item>
    </style>
</resources>

The main theme has a black background - the settings screen is then unreadable, since I have black text on this black background.

I tried many things, but I can not change the color of the text.

I needed to set the background color for the fragment container to white, while the settings fragment is active. Ugly hacking, not what I want to do.

+4
source share
2 answers

To answer my own question: my v14 / style.xml is now

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:editTextStyle">@style/Widget.EditText.White</item>
        <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
    </style>

    <style name="Widget.EditText.White" parent="@android:style/Widget.EditText">
        <item name="android:textColor">#ffffffff</item>
    </style>

    <style name="PreferenceThemeOverlay.v14">
        <item name="android:background">@color/settings_background</item>
        <item name="android:textColor">@color/settings_text_colour</item>
        <item name="android:textColorSecondary">@color/settings_text_colour_secondary</item>
    </style>
</resources>

Now my problem is ListPreference style.

? - , , . Grrrrrr!

+6

Source: https://habr.com/ru/post/1615336/


All Articles