title: Variable Height ScrollView
body: <p>In android, I have the following layout:</p>
  
  <p><a href="https://i.stack.imgur.com/pkRYy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pkRYy.jpg" alt="Android Layout"></a></p>
  
  <p>There are controls at the top, which loads data into the scrollview which the user can select and then another line of controls at the bottom with a save button.  My problem is I want to the scroll view to fill the display, but not push the bottom line out of the view.  If I set a fixed height on the scroll view, depending on the device it is either too small or too high.  How can I get it so that it is a variable height to match the display, but also always keeping the bottom line visible?</p>
  
  <p>(Edit: This is what I current attempt, it doesnt achieve the above):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout 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="match_parent"
      tools:context=".Find"&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;LinearLayout
              android:id="@+id/select_book_and_chapter"
              android:layout_width="393dp"
              android:layout_height="77dp"
              android:layout_marginEnd="8dp"
              android:layout_marginLeft="8dp"
              android:layout_marginRight="8dp"
              android:layout_marginStart="8dp"
              android:layout_marginTop="8dp"
              android:background="@drawable/border"
              android:orientation="horizontal"
              android:padding="0dp"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"&gt;
  
              &lt;android.support.v7.widget.AppCompatSpinner
                  android:id="@+id/books"
                  android:layout_width="280dp"
                  android:layout_height="55dp"
                  android:layout_margin="10dp"
                  android:layout_marginLeft="16dp"
                  android:layout_marginStart="16dp"
                  android:background="@drawable/noborder"
                  android:entries="@array/books"
                  android:gravity="center"
                  android:spinnerMode="dropdown"
                  android:theme="@style/large_spinner"
                  app:layout_constraintStart_toStartOf="parent"
                  tools:layout_editor_absoluteY="320dp" /&gt;
  
              &lt;android.support.v7.widget.AppCompatSpinner
                  android:id="@+id/chapters"
                  android:layout_width="81dp"
                  android:layout_height="54dp"
                  android:layout_margin="10dp"
                  android:layout_marginLeft="16dp"
                  android:layout_marginStart="16dp"
                  android:background="@drawable/noborder"
                  android:entries="@array/chapter_one"
                  android:gravity="center"
                  android:spinnerMode="dropdown"
                  android:theme="@style/large_spinner"
                  app:layout_constraintStart_toStartOf="parent"
                  tools:layout_editor_absoluteY="320dp" /&gt;
  
  
          &lt;/LinearLayout&gt;
  
          &lt;ScrollView
              android:id="@+id/scroll_verses"
              android:layout_width="387dp"
              android:layout_height="460dp"
              android:layout_marginEnd="8dp"
              android:layout_marginLeft="8dp"
              android:layout_marginRight="8dp"
              android:layout_marginStart="8dp"
              android:layout_marginTop="8dp"
              android:clipToPadding="false"
              android:fillViewport="true"
              app:layout_constraintTop_toBottomOf="@+id/linearLayout2"&gt;
  
              &lt;LinearLayout
                  android:id="@+id/select_verse"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical" /&gt;
  
  
          &lt;/ScrollView&gt;
  
  
          &lt;LinearLayout
              android:id="@+id/controls"
              android:layout_width="match_parent"
              android:layout_height="40dp"
              android:orientation="horizontal"
              android:visibility="gone"&gt;
  
              &lt;android.support.v7.widget.AppCompatSpinner
                  android:id="@+id/folders"
                  style="@style/Widget.AppCompat.Spinner.Underlined"
                  android:layout_width="299dp"
                  android:layout_height="36dp"
                  android:layout_marginBottom="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginStart="8dp"
                  android:background="@drawable/border"
                  android:spinnerMode="dropdown"
                  android:visibility="visible" /&gt;
  
              &lt;EditText
                  android:id="@+id/create_new_name"
                  android:layout_width="265dp"
                  android:layout_height="36dp"
                  android:layout_marginBottom="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginStart="8dp"
                  android:ems="10"
                  android:background="@drawable/noborder"
                  android:inputType="textPersonName"
                  android:text="New Folder Nam"
                  android:visibility="gone"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.578"
                  app:layout_constraintStart_toEndOf="@+id/create_new_text"
                  app:layout_constraintTop_toBottomOf="@+id/folders" /&gt;
  
              &lt;Button
                  android:id="@+id/cancel_new_folder"
                  android:layout_width="35dp"
                  android:layout_height="37dp"
                  android:layout_marginEnd="8dp"
                  android:layout_marginStart="8dp"
                  android:text="@string/cancel"
                  android:visibility="gone" /&gt;
  
              &lt;Button
                  android:id="@+id/save_scripture"
                  android:layout_width="wrap_content"
                  android:layout_height="37dp"
                  android:layout_marginEnd="8dp"
                  android:layout_marginStart="8dp"
                  android:onClick="saveToDB"
                  android:text="Save"
                  android:visibility="visible" /&gt;
  
          &lt;/LinearLayout&gt;
  
  
      &lt;/LinearLayout&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>