I am using the SettingsActivity generated from AndroidStudio (New, Activity, Settings Activity) that relies on AppCompatDelegate. I have succeeded to add a toolbar and to set a custom divider to the listview used for displayer preference headers as follows:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout root =
(LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
Toolbar toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar, root, false);
root.addView(toolbar, 0);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
ListView listView = getListView();
listView.setDivider(ContextCompat.getDrawable(this, R.drawable.settings_divider));
listView.setDividerHeight(1);
setupActionBar();
}
However, I cannot figure out how to increase the padding assocatied to each listview item neither how to increase spacing between the icon and the preference header title. Is it possible using styles or by passing a custom layout?