Open KimBunhong opened 7 years ago
Same issue here, setting a margin to the root of an item won't work.
Workaround: Put a FrameLayout around your item, and keep the margin on the child, or remove the margin and add padding to the FrameLayout.
@KimBunhong, @mihakrajnc Or you can use something like this:
final int space = getResources().getDimensionPixelSize(R.dimen.item_margin);
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.bottom = space;
outRect.right = space;
outRect.left = space;
outRect.top = space;
}
});
@illia-kramarenko Thanks! It worked.
Is this a bug in library? if not the this issue should be closed.
I tried to set margin to child item but its not work. How can I do?