title: Why does my ScrollView cut off after an imageView is added?
body: <p>When I try to add an imageView programmatically to the scrollView the bottom image gets cut off and I can't scroll down any further.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView 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/VVV"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"
      &gt;
  
  
      &lt;android.support.constraint.ConstraintLayout
          android:id="@+id/testLayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
  
          &lt;TextView
              android:id="@+id/text1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/large_text"
              app:layout_constraintLeft_toLeftOf="parent"
              app:layout_constraintRight_toRightOf="parent"
              app:layout_constraintTop_toTopOf="parent" /&gt;
  
          &lt;ImageView
              android:id="@+id/testImg"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:adjustViewBounds="true"
              android:src="@mipmap/ic_launcher"
              app:layout_constraintLeft_toLeftOf="parent"
              app:layout_constraintRight_toRightOf="parent"
              app:layout_constraintTop_toBottomOf="@id/text1" /&gt;
  
  
      &lt;/android.support.constraint.ConstraintLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>This is the java code for it:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
  
      ConstraintSet set = new ConstraintSet();
  
      ImageView imageView1 = new ImageView(this);
  
      imageView1.setImageResource(R.mipmap.ic_launcher_round);
  
  
      TextView textView = (TextView)findViewById(R.id.text1);
  
      int imgId = 100+1;
  
      imageView1.setId(imgId);
  
      imageView1.setAdjustViewBounds(true);
  
      ConstraintLayout layout = (ConstraintLayout) findViewById(R.id.testLayout);
  
      layout.addView(imageView1);
  
      set.clone(layout);
  
      set.connect(imgId, ConstraintSet.TOP, textView.getId(),ConstraintSet.BOTTOM);
  
      set.connect(imgId, ConstraintSet.LEFT, PARENT_ID,ConstraintSet.LEFT);
  
      set.connect(imgId, ConstraintSet.RIGHT, PARENT_ID,ConstraintSet.RIGHT);
  
      set.constrainWidth(imgId,ConstraintSet.MATCH_CONSTRAINT);
  
      set.constrainHeight(imgId, ConstraintSet.WRAP_CONTENT);
  
      set.connect(R.id.testImg, ConstraintSet.TOP, imgId , ConstraintSet.BOTTOM);
  
      ScrollView scrollView = (ScrollView) findViewById(R.id.VVV);
  
      scrollView.setFillViewport(true);
  
  
  
      set.applyTo(layout);
  </code></pre>
  
  <p>Here is an image of what is happening at the bottom of the scrollView and it no longer scrolls down.</p>
  
  <p><a href="https://i.stack.imgur.com/mPnAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPnAq.png" alt="enter image description here"></a></p>
  
  <p>I have tried to remove the fillViewport, and I have also tried to change it to add a Linear layout in the the constraint layout to see if its a problem with the constraint layout but it doesn't seem to work.</p>