You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry.My English not good.
我认为应该分成 GridItemDecoration 和 LinearItemDecoration 。在每个item的周围绘制想要的divider。
这样实现起来比较简单。如果是GridLayoutManager,垂直的时候,则应该在最后一列右边 和 最后一行的下面不添加分割线。
下面是我写的一个例子,相信你能看懂
I think it should be divided into GridItemDecoration and LinearItemDecoration.Draw divider around each item instead of entire row / column.
If it's GridLayoutManager, you should not add the dividing line in the last column to the right and below the last line when vertical and vice versa.
I just like to think of it, it's easier for me to think of it, as the work that I do.
Here is an example of what I wrote, I believe you can understand
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
outRect.left = getDividerSize();
outRect.bottom = getDividerSize();
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
RecyclerView.Adapter adapter = parent.getAdapter();
int itemCount = adapter.getItemCount();
int position = parent.getChildAdapterPosition(view);
int spanCount = gridLayoutManager.getSpanCount();
GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
int spanIndex = spanSizeLookup.getSpanIndex(position, spanCount);
int spanGroupIndex = spanSizeLookup.getSpanGroupIndex(position, spanCount);
int lastSpanGroupIndex = spanSizeLookup.getSpanGroupIndex(itemCount - 1, spanCount);
if (lastSpanGroupIndex == spanGroupIndex) outRect.bottom = 0;
if (spanIndex == 0) outRect.left = 0;
return;
}
Log.e(TAG, "RecyclerView must have GridLayoutManager");
}
The text was updated successfully, but these errors were encountered:
Sorry.My English not good.
我认为应该分成 GridItemDecoration 和 LinearItemDecoration 。在每个item的周围绘制想要的divider。
这样实现起来比较简单。如果是GridLayoutManager,垂直的时候,则应该在最后一列右边 和 最后一行的下面不添加分割线。
下面是我写的一个例子,相信你能看懂
I think it should be divided into GridItemDecoration and LinearItemDecoration.Draw divider around each item instead of entire row / column.
If it's GridLayoutManager, you should not add the dividing line in the last column to the right and below the last line when vertical and vice versa.
I just like to think of it, it's easier for me to think of it, as the work that I do.
Here is an example of what I wrote, I believe you can understand
The text was updated successfully, but these errors were encountered: