本文主要是介绍RecyclerView设置分隔线,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
添加默认分割线:高度为2px,颜色为灰色
recycleview.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL););
添加自定义分割线:可自定义分割线drawable
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
dividerItemDecoration.setDrawable(new ColorDrawable(Color.parseColor("#F5F5F5")));
recycleview.addItemDecoration(dividerItemDecoration);
参考:
https://blog.csdn.net/yancychas/article/details/77484659?locationNum=10&fps=1&utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-0&spm=1001.2101.3001.4242
这篇关于RecyclerView设置分隔线的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!