itgoyo / AndroidSummary

12 stars 4 forks source link

RecycleView设置自定义分割线 #127

Open itgoyo opened 3 years ago

itgoyo commented 3 years ago
                rv.setLayoutManager(new LinearLayoutManager(mContext));
                //添加自定义分割线
                DividerItemDecoration divider = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
                divider.setDrawable(ContextCompat.getDrawable(this,R.drawable.custom_chege_divider));
                rv.addItemDecoration(divider);
                rv.setAdapter(adapter);

custom_chege_divider

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <size android:height="20pt" />

</shape>
itgoyo commented 3 years ago

最简单的方式:

rvFail.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));