title: Layout margin not applying to constraint layout in RecyclerView
body: <p>I am attempting to add spacing between views in the RecyclerView. Using the RecyclerView I have a repeating list of constraint views using a view adapter. On each constraint view I have set the layout margin to equal 15dp like so <code>android:layout_margin="15dp"</code>. When previewing the layout in design view I can see that the margin is being applied however when the app is compiled the RecyclerView.</p>
  
  <p>The XML for the view being used inside the RecyclerView is as follows:</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_margin="15dp"
  android:background="@drawable/gradient"
  android:clipToPadding="true"
  android:minHeight="0dp"&gt;
  
  &lt;TextView
      android:id="@+id/moment_timestamp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="20dp"
      android:layout_marginTop="16dp"
      android:text="28 MAR @ 2:45pm"
      android:textColor="@android:color/white"
      app:layout_constraintEnd_toStartOf="@+id/moment_text"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;TextView
      android:id="@+id/moment_text"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginBottom="20dp"
      android:layout_marginEnd="20dp"
      android:layout_marginStart="20dp"
      android:layout_marginTop="40dp"
      android:background="@android:color/transparent"
      android:includeFontPadding="false"
      android:paddingVertical="0dp"
      android:text="A kind man held the door  open for me today"
      android:textAlignment="viewStart"
      android:textColor="@android:color/white"
      android:textSize="25sp"
      android:textStyle="bold"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/moment_timestamp" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>In design view, the component I am designing looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/eCSAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eCSAq.png" alt="design view"></a></p>
  
  <p>However, when compiled and being used in the RecyclerView, the margins are not applied:</p>
  
  <p><a href="https://i.stack.imgur.com/jUFrd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jUFrd.png" alt="compiled"></a></p>
  
  <p>This is my code where I inflate the layout. Originally the width of the view was not being applied so as shown in <a href="https://stackoverflow.com/questions/30691150/match-parent-width-does-not-work-in-recyclerview">this answer</a> I changed my code.</p>
  
  <pre><code>View view = inflater.inflate(R.layout.text_moment, null, false);
  RecyclerView.LayoutParams lp = new 
  RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  view.setLayoutParams(lp);
  return new MomentViewHolder(view);
  </code></pre>
  
  <p>Searched around quite extensively now and can't seem to find a solution. </p>