RecyclerView添加分割线:
代码很简单,
//添加自定义分割线
DividerItemDecoration divider = new DividerItemDecoration(this,DividerItemDecoration.VERTICAL);
divider.setDrawable(ContextCompat.getDrawable(this,R.drawable.custom_divider));
recyclerView.addItemDecoration(divider);
Drawable如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerColor="#ff00ff00" //绿色
android:endColor="#ff0000ff" //蓝色
android:startColor="#ffff0000" //红色
android:type="linear" />
<size android:height="3dp" />
</shape>
最快最简单....