You need to play with margin. Not filling out.
StaggeredGridLayoutManager sets the default value to "30dp" for each grid item.
It can be changed as follows:
class StaggeredListDecoration extends RecyclerView.ItemDecoration { public StaggeredListDecoration() { } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); BaseCard.CARD_TYPE viewType = (BaseCard.CARD_TYPE)view.getTag(); ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).leftMargin = 0; ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).rightMargin = 0; ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).topMargin = 0; ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).bottomMargin= 0; } }
Praga source share