consp1racy / android-support-preference

Android Preferences according to Material design specs
Apache License 2.0
331 stars 49 forks source link

How to separate PreferencesGroups one from the other? #68

Closed goldmont closed 7 years ago

goldmont commented 7 years ago

Hi,

What is the purpose of the PreferenceCategory.addPreference() method? I was wondering whether when I add preferences to PreferenceCategory, the PreferenceScreen, creates or not a group like a block of Preferences. If the PreferenceScreen creates a group of preferences, how can I separate the whole block from the other preferences? I would recreate a UI like the one in the screenshot below. Do you have a solution? Thanks!

Screenshot

consp1racy commented 7 years ago

Both PreferenceCategory and PreferenceScreen extend PreferenceGroup. PreferenceCategory displays as a header item and shows its children directly below. PreferenceScreen displays as a regular Preference which opens its children on a separate screen.

As for the screenshot UI it's not easily implemented with preference-v7 or even RecyclerView. I dumped the view hierarchy and it's a custom layout in a ScrollView.

goldmont commented 7 years ago

I solved by extending all preferences. It works like a charm! Thanks

consp1racy commented 7 years ago

I'm not sure why, replacing layouts may have worked just as well. AFAICS there isn't a perfect solution so I must wonder what you've come up with ^^