In my settings I have multiple preferences that don't have lines in between them, creating an ugly look. How do I fix this?
AndroidX
If using AndroidX, to show dividers you can simply add the following attributes in your Preference XML:
<Preference
...
app:allowDividerAbove="true"
app:allowDividerBelow="true"
... />
A more detailed answer here: https://stackoverflow.com/a/55981453/2836371
The following is for AndroidX:
In AndroidX, getListView() returns a RecyclerView.
Dividing lines can be added to RecyclerViews using .addItemDecoration()
This should be done after the RecyclerView has been inflated in onActivityCreated().
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
RecyclerView recyclerView = getListView();
DividerItemDecoration itemDecoration = new DividerItemDecoration(context, RecyclerView.VERTICAL);
recyclerView.addItemDecoration(itemDecoration);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With