I am developing an android application where I am using RecyclerView
. I need to add a divider in RecyclerView
.
I tried to add -
recyclerView.addItemDecoration(new
DividerItemDecoration(getActivity(),
DividerItemDecoration.VERTICAL_LIST));
below is my xml code -
<android.support.v7.widget.RecyclerView
android:id="@+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
/>
In the October 2016 update, the support library v25.0.0 now has a default implementation of basic horizontal and vertical dividers available!
https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html
recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));