So, I\'m facing a weird problem while implementing RecyclerView in my project. I have a custom decorator to implement a consistent top and bottom padding and a rather different
I was facing the same issue, the best solution is to make your item decoration while your are initializing your layout manager in the view holder , this resolves the problem you are facing example
public class GridViewHolder extends ViewHolder {
RecyclerView grid_list;
public GridViewHolder(View v) {
super(v);
this.grid_list = (RecyclerView) v.findViewById(R.id.home_screen_item_grid_recycler_view);
if (grid_list.getLayoutManager() == null) {
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(context, 4);
grid_list.setLayoutManager(mLayoutManager);
grid_list.addItemDecoration(new GridSpacingItemDecoration(4, 3, false));
}
}
}