recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL));
drawable目录下新建bg_decoration.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerColor="@color/colorAccent"
android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimaryDark"
android:type="linear"/>
<size android:height="3dp"/>
</shape>
style.xml下的主题样式中加入
<item name="android:listDivider">@drawable/bg_decoration</item>