Android horizontal preference divider in user preferences?

I created my own preference objects that extend Preference. I only created them because there are no settings for these custom data types.

Everything works, but my user settings do not have the same appearance, because they lack the horizontal separator that the system preference objects have. I was looking for code that creates a horizontal separator, but I cannot find where this is done.

The built-in divider is not just a thin panel. There is a bit of a gradient for this. I think it may be in the layout file, but I can not find the layouts for the system settings.

Has anyone understood how this is implemented?

+5
source share
1 answer

A very old post, but for those who stumble upon this. I was not sure if the OP was asking how to change the separator or where the separators came from. Therefore, I will appeal to both.

As
Preferences uses ListViewto fill in all the individual settings. This means that you can change the delimiter using the .setDivider()from method ListView. A PreferenceActivitywill already have a method getListView()for you. However, for PreferenceFragmentsjust use the identifier android.R.id.listto find it.

If you do not want to change the divisor through the code, you can always use the theme by overriding the attribute listDivider. For instance:

<item name="android:listDivider">@drawable/custom_divider</item>

Please note that this will change the separator for EVERYONE ListViewin your application.


listDivider , Android . Android SDK :
[Android SDK]//[API]/data/res/drawable- [DPI]/

`* divider_horizontal *`, . .

+3

All Articles