先上效果
直接上代码
使用默认方式
1 | recyclerView.addItemDecoration( new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL)); |
使用自定义颜色及高度(通过shape 控制颜色及高度)
1 | DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL); |
R.drawable.shape_RecyclerView_divider1
2
3
4
5
6<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#F3F5F7"/>
<size android:height="2dp"/>
</shape>
DividerItemDecoration源码
1 |
|