point1
继承RecyclerView.ItemDecoration主要有以下三个方法:
- getItemOffsets(rect ,view ,recyclerView,state);
设置绘制区域rect.set(x,x,x,x)。
- ondraw(cavas,recyclerview,state)
找好可以绘制的区域,用cavas绘制。先于itemView的ondraw方法。
- ondrawover(cavas,recyclerview,state);
这个跟ondraw差不多,后于itemView的ondraw方法。
point2 瀑布流的decoration
1 | StaggeredGridLayoutManager.LayoutParams lp = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams(); |
两列的时候,spanIndex要么为0,要么为1,0表示在左边,1表示在右边。