Android: How to maximize PreferenceFragment width (or get rid of margin)?
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(android.R.id.list);
ViewGroup parent = (ViewGroup)lv.getParent();
parent.setPadding(0, 0, 0, 0);
Finally, I found the solution to this.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
if(v != null) {
ListView lv = (ListView) v.findViewById(android.R.id.list);
lv.setPadding(10, 10, 10, 10);
}
return v;
}
You can set padding by using: setPadding();