title: Center Columns in RecyclerView
body: <p>I'm trying to create a dynamic <code>RecyclerView</code> layout.  I am using a <code>GridLayoutManager</code> with three columns. </p>
  
  <p>I need to wrap each grid item and center the columns (like attached).</p>
  
  <p>I have tried a <code>StaggeredGridLayout</code>, I have tried a <a href="https://gist.github.com/c0nnector/5f80e19d9ba6d562fbd5" rel="nofollow noreferrer">WrapGridLayoutManager</a>  but neither of these worked.</p>
  
  <p>Here is my <code>RecyclerView</code>:</p>
  
  <pre><code> &lt;android.support.v7.widget.RecyclerView
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/categories_grid"
          android:layout_marginTop="@dimen/feed_item_margin"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/android.support.v7.widget.RecyclerView&gt;
  </code></pre>
  
  <p>and my <code>RecyclerView</code> item:</p>
  
  <pre><code> &lt;LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:background="@drawable/first_time_category_unselected"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:id="@+id/category_name"
          android:layout_marginLeft="@dimen/feed_item_margin"
          android:layout_gravity="center_vertical"
          android:textColor="@color/black_colour"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;ImageView
          android:id="@+id/category_status_icon"
          android:layout_gravity="center_vertical"
          android:background="@drawable/icon_follow"
          android:layout_marginLeft="@dimen/feed_item_margin"
          android:layout_marginRight="@dimen/feed_item_margin"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is the decoration I'm using to implement grid spacing:</p>
  
  <pre><code>public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
      private int halfSpace;
  
      public SpacesItemDecoration(int space) {
          this.halfSpace = space / 2;
      }
  
      @Override
      public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
  
          if (parent.getPaddingLeft() != halfSpace) {
              parent.setPadding(halfSpace, halfSpace, halfSpace, halfSpace);
              parent.setClipToPadding(false);
          }
  
          outRect.top = halfSpace;
          outRect.bottom = halfSpace;
          outRect.left = halfSpace;
          outRect.right = halfSpace;
      }
  }
  </code></pre>
  
  <p>This is what I'm trying to achieve:
  <a href="https://i.stack.imgur.com/ToRWT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ToRWT.png" alt="what I&#39;m trying to achieve"></a></p>
  
  <p>This is what I am getting:
  <a href="https://i.stack.imgur.com/Pl9lt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pl9lt.png" alt="enter image description here"></a>
  If anyone can help on this I'd greatly appreciate it</p>