I want to add divider lines in my RecyclerView
Layout
. I already searched some time, but I can only find solutions that utilise RecyclerView.addItemDecoration
, which adds the divider between all items. I could create a layout that has a single line and add that to the RecyclerView
, but that doesn't seem like an elegant solution to me.
DividerItemDecoration myDivider = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
myDivider.setDrawable(ContextCompat.getDrawable(context, R.drawable.cutm_dvdr));
yourRecyclerView.addItemDecoration(myDivider);
add cutm_dvdr.xml in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="#e20" />
</shape>
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