title: GridLayoutManager spacing is not consistent
body: <p>So i am using <code>RecyclerView</code> with <code>GridLayoutManager</code> the spacing between the items is not consistent around the item </p>
  
  <p>This is how it looks in 4 x 4 Grid</p>
  
  <p><a href="https://i.stack.imgur.com/PEAWr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PEAWr.png" alt=""></a></p>
  
  <p>This is how it looks in 5 x 5 grid</p>
  
  <p><a href="https://i.stack.imgur.com/W8YAg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W8YAg.png" alt=""></a></p>
  
  <p>I already tried many solution from <a href="https://stackoverflow.com/questions/24618829/how-to-add-dividers-and-spaces-between-items-in-recyclerview/27664023#27664023">this</a> and <a href="https://gist.github.com/alexfu/f7b8278009f3119f523a" rel="nofollow noreferrer">this</a> and <a href="https://gist.github.com/liangzhitao/e57df3c3232ee446d464" rel="nofollow noreferrer">this</a></p>
  
  <p>But nothing worked for me</p>
  
  <p>Here is my how i am setting my adapter</p>
  
  <pre><code>mLayoutManager = new GridLayoutManager(mContext, 5);
          mRecyclerView.setLayoutManager(mLayoutManager);
  
          int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing);
          mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
  </code></pre>
  
  <p>And this is my <code>SpacesItemDecoration</code> class</p>
  
  <pre><code>public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
      private int space;
  
      public SpacesItemDecoration(int space) {
          this.space = space;
      }
  
      @Override
      public void getItemOffsets(Rect outRect, View view,RecyclerView parent, RecyclerView.State state)
      {
          outRect.left = space;
          outRect.right = space;
          outRect.top = space;
          outRect.bottom = space;
  
          // Add top margin only for the first item to avoid double space between items
          if (parent.getChildLayoutPosition(view) == 0)
          {
              outRect.top = space;
          }
          else
          {
              outRect.top = 0;
          }
      }
  }
  </code></pre>
  
  <p>I don't know why it is not working for me </p>
  
  <blockquote>
    <p>There is no margin or padding to my recyclerview &amp; item</p>
  </blockquote>