Android: How to maximize PreferenceFragment width (or get rid of margin)?

Finally, I found the solution to this.

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);
    if(v != null) {
        ListView lv = (ListView) v.findViewById(;
        lv.setPadding(10, 10, 10, 10);
    return v;

You can set padding by using: setPadding();

Just an addition to this; the accepted answer did not work for me because the ListView itself does not have any padding set, it is set on the parent view (usually a LinearLayout). So instead, the following was necessary:

ListView lv = (ListView) findViewById(;
ViewGroup parent = (ViewGroup)lv.getParent();
parent.setPadding(0, 0, 0, 0);

getListView().setPadding(left, top, right, bottom)

Make sure to call it after your view has been created (not onCreate).

Keep in mind that the int you pass in is in pixels, not dp. To convert from dp to pixels see this answer.