I started dealing with preferences in a PreferenceFragment
. Here's what I have:
I'm trying to:
get rid of the dividers between items. I suppose this can be defined from styles, but I can't figure out how. I tried getting the preference
ListView
at runtime callingfindViewById(android.R.id.list)
, as I read somewhere, but it returns null.set new, full width dividers right on top of the headers, as seen here. For example in this case I want a full width divider right above "Statistiche", but not above "Generali" which is on top of the list.
The only way that comes to my mind is setting dividers as fake preferences, like with:
<Preference
android:layout="@layout/divider" //here I set width and a divider resource
/>
<PreferenceCategory ... />
The main issue here is that my PreferenceFragment
(or the ActionBarActivity
it's in) has some left/right padding, that make any divider I add into preferences.xml not cover the entire width.
So my question are:
How can I get rid of default, item-item dividers that you can see in the image?
How can I set full width dividers right above headers, or how can I get rid of internal fragment/activity padding? Of course my activity layout has no (explicit) padding whatsoever.
list = findViewById(android.R.id.list)
and thenlist.setDivider(null)
. To avoid NPE, you need to call thisonResume
rather thanonCreate
. As for the other issue, I will try to post a full answer today. – Selassiepublic class SettingsFragment extends PreferenceFragment
. So in this case how can we achieve? any help. – Epicgetview()
returns me NULL, if i callView rootView = getView();
like this – Epic