前言
RecyclerView目前来说,是日常开发中使用最多的控件,功能强大而且复杂。而Item Decoration作为RecyclerView开发过程中不可或缺的部分,需要深入的了解一下。
源码分析
/**
* An ItemDecoration allows the application to add a special drawing and layout offset
* to specific item views from the adapter's data set. This can be useful for drawing dividers
* between items, highlights, visual grouping boundaries and more.
*
* <p>All ItemDecorations are drawn in the order they were added, before the item
* views (in {@link ItemDecoration#onDraw(Canvas, RecyclerView, RecyclerView.State) onDraw()}
* and after the items (in {@link ItemDecoration#onDrawOver(Canvas, Recy