title: How to remove spacing between rows in RecyclerView using GridLayoutManager
body: <p>I am trying to have a full screen grid with a <code>RecyclerView</code> with a <code>GridLayoutManager</code> but for some reason a horizontal space is added between the rows and at the top and bottom of my <code>RecyclerView</code>. I can't get rid of it. I searched for solutions and tried an <code>ItemDecorator</code> by setting the dimensions to 0 explicitly but that didn't work. Nothing else worked.</p>
  
  <p>The <a href="http://imgur.com/FbMGe3s" rel="noreferrer">image</a>.</p>
  
  <p>The code for my <code>ItemDecorator</code> is pretty standard, included.</p>
  
  <pre><code>private class RecyclerViewItemDecorator extends RecyclerView.ItemDecoration {
      private int spaceInPixels;
  
      public RecyclerViewItemDecorator(int spaceInPixels) {
          this.spaceInPixels = spaceInPixels;
      }
  
      @Override
      public void getItemOffsets(Rect outRect, View view,
                                 RecyclerView parent, RecyclerView.State state) {
          outRect.left = spaceInPixels;
          outRect.right = spaceInPixels;
          outRect.bottom = spaceInPixels;
          if (parent.getChildLayoutPosition(view) == 0) {
              outRect.top = spaceInPixels;
          } else {
              outRect.top = 0;
          }
      }
  }
  </code></pre>
  
  <p>These are the layout files I use.</p>
  
  <p><strong>/layout/activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.korah.moviesapp.MainActivity"&gt;
  
      &lt;fragment
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/main_fragment"
          android:name="com.example.korah.moviesapp.MainActivityFragment"
          tools:layout="@layout/activity_main_fragment"
          &gt;
      &lt;/fragment&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>/layout/activity_main_fragment.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/movies_recycler"
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;    
      &lt;/android.support.v7.widget.RecyclerView&gt;
  </code></pre>
  
  <p><strong>/layout/activity_movies_grid.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;ImageView
      android:id="@+id/imageView"
      android:src="@drawable/interst"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android" /&gt;
  </code></pre>