title: How to programmatically access the current constraints of views in a ConstraintLayout?
body: <p>I can programmatically modify constraints of a view in a ConstraintLayout using ConstraintSet but before applying modifications, I want to test that it hasn't been done already. To do this I need to programmatically access the current constraints of a view in a ConstraintLayout.</p>
  
  <p>For example, here I want to remove the constraint between the top of the TextView 'title' and the bottom of TextView view 'subtitle'. Then Constrain the top of TextView 'title' to the bottom of 'videoView'. But first I need to check if TextView 'title' isn't already constrained to the bottom of 'videoView'  (code modified from <a href="https://developer.android.com/reference/android/support/constraint/ConstraintSet.html" rel="noreferrer">android's official website</a>). Note, I can't insert the final line of HTML on this website, it's /android.support.constraint.ConstraintLayout in angle brackets.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  ConstraintSet mConstraintSet = new ConstraintSet(); // create a Constraint Set
  ConstraintLayout mConstraintLayout; // cache the ConstraintLayout
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mConstraintLayout = (ConstraintLayout) findViewById(R.id.root);
      mConstraintSet.clone(mConstraintLayout); // get constraints from ConstraintSet
  }
  
  public void userDoesSomething(View v) {
      //test if title has already been constrained to bottom of videoView
      if (mConstraintLayout 'TITLE' IS NOT CONSTRAINED TO THE BOTTOM OF 'VIDEOVIEW'){
          mConstraintSet.connect(R.id.Title, ConstraintSet.TOP, R.id.videoView, ConstraintSet.BOTTOM); // set new constraints to ConstraintSet
          mConstraintSet.applyTo(mConstraintLayout); // set new constraints to ConstraintLayout
      }
  }
  </code></pre>
  
  <p>}</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:id="@+id/root"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.test.MainActivity"
  android:orientation="vertical"&gt;
  
  &lt;VideoView
      android:id="@+id/videoView"
      android:layout_width="match_parent"
      android:layout_height="100dp"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
  
      /&gt;
  
  &lt;TextView
      android:id="@+id/subtitiles"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:layout_constraintTop_toBottomOf="@+id/videoView"
      app:layout_constraintLeft_toLeftOf="parent"
      android:gravity="center"
      android:text="The problem with this pond is that there are too many toads"
      android:textSize="25sp"
      android:background="@android:color/white"
  
      /&gt;
  
  &lt;TextView
      android:id="@+id/title"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:layout_constraintTop_toBottomOf="@+id/subtitiles"
      app:layout_constraintLeft_toLeftOf="parent"
      android:gravity="center"
      android:text="Toad"
      android:textSize="25sp"
      android:background="@android:color/white"
      /&gt;
  </code></pre>
  
  <p></p>