Android ScrollView gets cut off at the bottom
<p>I am trying to programmatically add form fields picked from an HTML file to a LinearLayout. I have a next button at the bottom but it keeps getting cut off in the display. I tried it on a tablet and it still doesnt show up. </p>

<p>Here's a screenshot of the app:
<a href="https://i.stack.imgur.com/EPBb6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EPBb6.png" alt="screenshot"></a></p>

<p>As you can see, the elements are getting rendered but the last one runs off the screen for some reason. </p>

<p>Fragment's XML:</p>

<pre><code>&lt;FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".dataInput.PropertyInfoFragment"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"&gt;

    &lt;ScrollView
        android:fillViewport="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"&gt;

            &lt;LinearLayout
                android:id="@+id/linear_layout_property_info"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"&gt;

            &lt;/LinearLayout&gt;
            &lt;Button
                android:id="@+id/nextButton"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/next"
                android:background="@color/colorPrimary"
                android:textColor="@android:color/white"/&gt;
        &lt;/LinearLayout&gt;

    &lt;/ScrollView&gt;

&lt;/FrameLayout&gt;
</code></pre>

<p>Calling Activity's XML: </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.design.widget.CoordinatorLayout 
    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/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".dataInput.DataInputActivity"&gt;

    &lt;android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"&gt;

        &lt;android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay"&gt;

        &lt;/android.support.v7.widget.Toolbar&gt;

        &lt;android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" /&gt;

    &lt;/android.support.design.widget.AppBarLayout&gt;

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;

    &lt;android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_media_play" /&gt;

&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p>I am calling a method <code>formInflator</code> that I made in the fragment's <code>onCreateView</code> and passing the LinearLayout from the fragment and an <code>Elements</code> object (from Jsoup library) which contains all the Elements that I want to put inside the LinearLayout:</p>

<pre><code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_property_info, container, false);
    nextButton = (Button) view.findViewById(R.id.nextButton);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonPressed();
        }
    });

    helpers.formInflator((LinearLayout) view.findViewById(R.id.linear_layout_property_info), generator.propertyTextElements);
    return view;

}
</code></pre>

<p>Here's the method <code>formInflator</code>:</p>

<pre><code>public void formInflator(LinearLayout parentLayout, Elements formElements) {
    TextInputLayout index = null;
    for(Element textField : formElements) {
        TextInputEditText editText = new TextInputEditText(context);
        editText.setId(View.generateViewId());
        editText.setHint(textField.id());
        editText.setText(textField.text());
        LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        editText.setLayoutParams(editTextParams);

        TextInputLayout textInputLayout = new TextInputLayout(context);
        textInputLayout.setId(View.generateViewId());
        textInputLayout.setTag(textField.id());
        RelativeLayout.LayoutParams textInputLayoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        if (index == null)
            index = textInputLayout;
        else
            textInputLayoutParams.addRule(RelativeLayout.BELOW, index.getId());

        textInputLayout.setLayoutParams(textInputLayoutParams);
        textInputLayout.addView(editText, editTextParams);

        parentLayout.addView(textInputLayout, textInputLayoutParams);
        index = textInputLayout;
    }
}
</code></pre>

<p>Any idea what I am doing wrong?</p>