title: ItemDecorator for RecyclerView with CardViews not working
body: <p>I am trying to use ItemDecorator to achieve spacing between CardViews inside a RecyclerView. For that I am using as reference <a href="https://stackoverflow.com/a/28533234/2930101">this</a> answer but the spacing isn't applied. I Also tried with <a href="https://stackoverflow.com/a/30794046/2930101">this</a> answer but no avail.</p>
  
  <p>Here is the XML for the RecyclerView:</p>
  
  <pre><code>&lt;FrameLayout 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.company.name.MyFragment"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
              android:id="@+id/recyclerviewId"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clipToPadding="false"
              /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>Here is the XML for the CardView:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:card_view="http://schemas.android.com/apk/res-auto"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/cardView"
          card_view:cardElevation="2dp"
          &gt;
  
      &lt;android.support.constraint.ConstraintLayout
              android:id="@+id/constraintLayout"
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  
          &lt;ImageView
                  android:id="@+id/imageView"
                  android:layout_width="100dp"
                  android:layout_height="98dp"
                  card_view:srcCompat="@mipmap/ic_launcher"
                  card_view:layout_constraintTop_toTopOf="parent"
                  card_view:layout_constraintLeft_toLeftOf="parent"/&gt;
      &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>The code for the item decorators are the ones presented in the consulted answers.</p>
  
  <p>What could be the reason for the spacing not to be applied?</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>Here's the code to assign the item decorator:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
  {
      ...
  
      myRecyclerView.setLayoutManager(new GridLayoutManager(activity, 2));
      myRecyclerView.addItemDecoration(new SpacingGridView(activity, R.dimen.my_spacing), 0);
  
      ... 
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState)
  {
      super.onActivityCreated(savedInstanceState)
  
      MyAdapter adapter = MyAdapter(getData());
      myRecyclerView.setAdapter(adapter);
  }
  </code></pre>