且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两个RecyclerView.ItemDecoration彼此重叠

更新时间:2022-11-17 20:26:01

我在此处 a>解决两个ItemDecoration重叠的问题. (有关更多详细信息,请通过@bejibx查看评论)

I used this code from here to solve two ItemDecoration overlap. (For more details check comment by @bejibx)

public void drawVertical(Canvas c, RecyclerView parent)
{
    RecyclerView.LayoutManager manager = parent.getLayoutManager();
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++)
    {
        final View child = parent.getChildAt(i);
        final int top = manager.getDecoratedBottom(child);
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}