Two Recyclerview.itemdecoration Overlapping Each Other
In our app we use two ItemDecorations in RecyclerView. One is StickyHeader to show dates, and other is header to show New Messages header. Problem is that when they are added to sa
Solution 1:
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);
}
}
Post a Comment for "Two Recyclerview.itemdecoration Overlapping Each Other"