Reputation: 12861
I have settings screen which is Fragment
extending PreferencesListFragment
. In which first there is main PreferenceScreen
in which there are multiple nested PreferenceScreen
like below layout:
<PreferenceScreen>
//general settings
<PreferenceScreen android:key="adv_settings">
//more advanced settings
</PreferenceScreen>
</PreferenceScreen>
Main Settings list is looks fine as shown below:
But when i clicked on one of PreferenceScreen
say "Call" then Call PreferenceScreen
opens as shown below with added left and right side padding
.
I am using Custom layout for PreferenceScreen
in which i do not give any padding to layout.
I am creating PreferenceScreen
programatically
I have followed this and this about removing padding by setting padding to ListView
but i did not helped.
Any help will be appreciated.
Upvotes: 1
Views: 848
Reputation: 152
In my case I had to use R.id.list
instead of android.R.id.list
Upvotes: 0
Reputation: 41
The padding is caused by the parent ListView
in the PreferenceScreen
containing your settings. I had the same problem when I created my custom preferences from code. If you are using a PreferenceFragment
to create your Preferences, just go to the onActivityCreated
function of the PreferenceFragement
and do the following to remove the padding:
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View lv = getView().findViewById(android.R.id.list);
if (lv != null) lv.setPadding(0, 0, 0, 0);
}
Upvotes: 1