Change height of Preference items

Viewed 5221

I have a PreferenceFragment subclass. I want each one of its items (Preferences and SwitchPreferences) to have a height of 120dp. How to do that?

Here is the related code:

public class SettingsFragment extends PreferenceFragment {
        public SettingsFragment() {}
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.main);         
        }
}

and

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <SwitchPreference android:key="app_main_switch"
                      android:title="@string/app_name"
                      android:defaultValue="true"/>
    <Preference android:title="@string/events_lowercase"
                android:dependency="app_main_switch">
        <intent android:targetPackage="hu.ppke.itk.marma.android.bead" 
                android:targetClass="hu.ppke.itk.marma.android.bead.EventList"/>
    </Preference>
    <Preference android:title="@string/filters_lowercase"
                android:dependency="app_main_switch">
        <intent android:targetPackage="hu.ppke.itk.marma.android.bead" 
                android:targetClass="hu.ppke.itk.marma.android.bead.FilterList"/>
    </Preference>
    <SwitchPreference android:dependency="app_main_switch"
                      android:key="learn_switch"
                      android:defaultValue="false"
                      android:title="@string/learning"/>
</PreferenceScreen>

Here is how it looks like now:

enter image description here

So I want all four items of the list to have a height of 120dp. As you can see I'm not the one creating the ListView, it's created internally. I tried to retrieve it with

findViewById(android.R.id.list)

but iterating over its elements gives Preference objects which do not allow me to set the height.

3 Answers
Related