title: How do margins in chains work in ConstraintLayout 1.1.0 (beta)
body: <p>I have had a couple of my layouts blow up since changing over to ConstraintLayout version 1.1.0-beta4. Before I make any changes, I want to get a better understanding of how margins work in <code>ConstraintLayout</code> chains. In the following, I compare a layout in <code>ConstraintLayout</code> version 1.0.2 to version 1.1.0-beta4, but I believe that the issue first arose in 1.1.0-beta2.</p>
  
  <p>My goal is to have some text views stretch across the screen with gaps between the 1st and 2nd text views and the 2nd and 3rd text views. The background should show in these margins. To do this, I create a horizontal chain and specify an end margin from the left text view to the center text view and an end margin from the center text view  to the right text view. The horizontal chain style is <code>spread_inside</code>. </p>
  
  <p><strong>Example 1 - Using ConstraintLayout version 1.0.2</strong></p>
  
  <p>This is how things look in version 1.0.2 and is what I expect.</p>
  
  <p><a href="https://i.stack.imgur.com/9mHz5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9mHz5.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout 
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:background="@android:color/holo_blue_light"&gt;
  
      &lt;TextView
          android:id="@+id/tvLeft"
          android:layout_width="0dp"
          android:layout_height="35dp"
          android:layout_marginEnd="8dp"
          android:background="@android:color/white"
          android:gravity="center"
          android:text="Text1"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toStartOf="@+id/tvCenter"
          app:layout_constraintHorizontal_chainStyle="spread_inside"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          tools:ignore="HardcodedText" /&gt;
  
      &lt;TextView
          android:id="@+id/tvCenter"
          android:layout_width="0dp"
          android:layout_height="35dp"
          android:layout_marginEnd="8dp"
          android:background="@android:color/white"
          android:gravity="center"
          android:text="Text2"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toStartOf="@+id/tvRight"
          app:layout_constraintStart_toEndOf="@+id/tvLeft"
          app:layout_constraintTop_toTopOf="parent"
          tools:ignore="HardcodedText" /&gt;
  
      &lt;TextView
          android:id="@+id/tvRight"
          android:layout_width="0dp"
          android:layout_height="35dp"
          android:background="@android:color/white"
          android:gravity="center"
          android:text="Text3"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toEndOf="@+id/tvCenter"
          app:layout_constraintTop_toTopOf="parent"
          tools:ignore="HardcodedText" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>Example 2 - Using ConstraintLayout version 1.1.0-beta4</strong></p>
  
  <p>This same layout looks like the following in version 1.1.0-beta4 of <code>ConstraintLayout</code>. Notice that the margins have disappeared. I expect that this should look the same as example 1, but it doesn't.</p>
  
  <p><a href="https://i.stack.imgur.com/bweo2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bweo2.png" alt="enter image description here"></a></p>
  
  <p><strong>Example 3 - Using ConstraintLayout version 1.1.0-beta4 with start margin</strong></p>
  
  <p>If I take this same layout and simply add a start margin of <code>8dp</code> to the right text view (<code>tvRight</code>), my margins reappear not only between the center and right text views but also between the left and center textviews although I have not changed the margins there.</p>
  
  <p><a href="https://i.stack.imgur.com/8Nj51.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8Nj51.png" alt="[image]"></a></p>
  
  <p>This is more than just the previously set margins suddenly being honored. If I set the start margin on the rightmost text view to '48dp', what appears to be a <code>48dp</code> margin also appears between the left and center text views.</p>
  
  <p><a href="https://i.stack.imgur.com/CBWzn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CBWzn.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout 
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:background="@android:color/holo_blue_light"&gt;
  
  &lt;!-- TextViews tvLeft &amp; tvRight not shown but are the same as above.--&gt;
  
  &lt;TextView
      android:id="@+id/tvRight"
      android:layout_width="0dp"
      android:layout_height="35dp"
      android:layout_marginStart="48dp"
      android:background="@android:color/white"
      android:gravity="center"
      android:text="Text3"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toEndOf="@+id/tvCenter"
      app:layout_constraintTop_toTopOf="parent"
      tools:ignore="HardcodedText" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;  
  </code></pre>
  
  <p>So, my question is, "Why am I seeing these results?" How are margins handled in <code>ConstraintLayout</code> chains, especially <code>spread_inside</code> chains? Has there been a change in the way chain margins are handled, or am I missing something? I am looking for an explanation or a reference to some documentation that explains all this.</p>