title: RecyclerView in NestedScrollView to fill remaining space
body: <p>I have view hierarchy like below:
  <strong>NestedScrollView > ConstraintLayout > [Layout,Layout, RecyclerView]</strong> </p>
  
  <p>I want my RecyclerView to fill remaining space in Nested ScrollView. 
  My ConstaintLayout has <strong>wrap_content</strong> layout_height. Child Layouts has fixed height set in dp units. And I want to set RecyclerView height to adjust remaining space inside ConstraintLayout. </p>
  
  <p>I am setting height of ConstraintLayout programatically to calculated value like height of both child Layouts + Screen Height. I nearly works, but RecyclerView with current wrap_content height seem to stretch out of its parent ConstraintLayout boundaries not fitting its bottom margin. If I constraint to bottom of parent ConstrintLayout then it is moved over the above child Layouts content. If I set 0dp height of RecyclerView then it has 0dp height not streching inside available space. Maybe only option is to set height of RecyclerView to fixed dp size programatically ex. onMeasure(), onLayout or other callback methods in Views, Fragments, etc? </p>
  
  <p>Any Idea?</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;android.support.constraint.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:myapp="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          tools:context=".ui.billing.BillingFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;com.domain.AppName.base.ui.billing.BillingNestedScrollView
          android:layout_width="0dp"
          android:layout_height="0dp"
  
          android:overScrollMode="never"
          android:fillViewport="true"
  
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"
  
          android:background="@color/theMinteFormBackground"&gt;
          &lt;android.support.constraint.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:clickable="true"
              android:focusable="true"
              android:focusableInTouchMode="true"&gt;
  
              &lt;com.domain.AppName.base.utils.design.ShadowLayout
                  android:id="@+id/creditCardSectionLayout"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="16dp"
                  android:layout_marginStart="16dp"
                  android:layout_marginEnd="16dp"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  myapp:sl_shadow_color="#AAD4D4D4"
                  myapp:sl_shadow_angle="360"
                  myapp:sl_shadow_distance="0dp"
                  myapp:sl_shadow_radius="4dp"
                  myapp:sl_shadow_top="true"
                  myapp:sl_shadow_bottom="true"
                  myapp:sl_shadow_right="true"
                  myapp:sl_shadow_left="true"
                  myapp:sl_shadowed="true"&gt;
                  &lt;android.support.constraint.ConstraintLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="@android:color/white"&gt;
  
                      &lt;com.domain.AppName.base.ui.forms.FormHeaderView
                          android:id="@+id/creditCardHeaderFormView"
                          android:layout_width="0dp"
                          android:layout_height="50dp"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintTop_toTopOf="parent"
                          myapp:labelText="@string/billing_payment_info_section_header"
                          style="@style/FormSectionHeaderStyle" /&gt;
  
                      &lt;Button
                          android:id="@+id/cancelCreditCardButton"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="@string/payment_info_form_cancel_button_title"
                          app:layout_constraintEnd_toEndOf="@id/creditCardHeaderFormView"
                          app:layout_constraintTop_toTopOf="@id/creditCardHeaderFormView"
                          app:layout_constraintBottom_toBottomOf="@id/creditCardHeaderFormView"
                          style="@style/CancelCreditCardButtonStyle"
                          android:visibility="invisible" /&gt;
  
                      &lt;Button
                          android:id="@+id/scanCreditCardButton"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="@string/payment_info_form_scan_card_button_title"
                          app:layout_constraintEnd_toEndOf="@id/creditCardHeaderFormView"
                          app:layout_constraintTop_toTopOf="@id/creditCardHeaderFormView"
                          app:layout_constraintBottom_toBottomOf="@id/creditCardHeaderFormView"
                          style="@style/ScanCreditCardButtonStyle" /&gt;
  
                      &lt;com.domain.AppName.base.ui.forms.material.ValidableCardNumberInput
                          android:id="@+id/cardNumberInput"
                          android:layout_width="0dp"
                          android:layout_height="50dp"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@id/creditCardHeaderFormView"
                          android:layout_marginStart="16dp"
                          android:layout_marginEnd="16dp"
                          android:layout_marginTop="16dp"
  
                          myapp:hintText="@string/payment_info_form_card_number_label"
                          myapp:inputType="number"
                          myapp:inputText=""
                          myapp:iconDrawable="@drawable/baseline_credit_card_24"
  
                          myapp:isRequired="true"
                          myapp:validationEmptyError="@string/validation_card_number_empty"
                          myapp:requireType="none"
                          myapp:validationError="@string/validation_card_number_error"
                          myapp:validationErrorColor="@color/theMinteValidationError" /&gt;
  
                      &lt;com.domain.AppName.base.ui.forms.material.ValidableExpiryDateInput
                          android:id="@+id/expirationDateInput"
                          android:layout_width="0dp"
                          android:layout_height="50dp"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@id/cardNumberInput"
                          android:layout_marginStart="16dp"
                          android:layout_marginEnd="16dp"
                          android:layout_marginTop="16dp"
  
                          myapp:hintText="@string/payment_info_form_expiration_date_label"
                          myapp:inputType="number"
                          myapp:inputText=""
  
                          myapp:isRequired="true"
                          myapp:validationEmptyError="@string/validation_expiration_date_empty"
                          myapp:requireType="regex"
                          myapp:regexPattern="\\d{1,2}/\\d{2,4}"
                          myapp:validationError="@string/validation_expiration_date_error"
                          myapp:validationErrorColor="@color/theMinteValidationError" /&gt;
  
                      &lt;com.domain.AppName.base.ui.forms.material.ValidableTextInput
                          android:id="@+id/cvcTextInput"
                          android:layout_width="0dp"
                          android:layout_height="50dp"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@id/expirationDateInput"
                          app:layout_constraintBottom_toBottomOf="parent"
                          android:layout_margin="16dp"
  
                          myapp:hintText="@string/payment_info_form_cvc_label"
                          myapp:inputType="number"
                          myapp:inputText=""
  
                          myapp:isRequired="true"
                          myapp:validationEmptyError="@string/validation_cvc_empty"
                          myapp:requireType="none"
                          myapp:minLength="3"
                          myapp:maxLength="4"
                          myapp:validationError="@string/validation_cvc_error"
                          myapp:validationErrorColor="@color/theMinteValidationError" /&gt;
                  &lt;/android.support.constraint.ConstraintLayout&gt;
              &lt;/com.domain.AppName.base.utils.design.ShadowLayout&gt;
  
              &lt;include
                  android:id="@+id/googlePayFormView"
                  layout="@layout/view_google_pay"
                  android:layout_width="0dp"
                  android:layout_height="82dp"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintTop_toBottomOf="@id/creditCardSectionLayout" /&gt;
  
             &lt;android.support.v7.widget.RecyclerView
                 android:id="@+id/recyclerView"
                 android:layout_width="0dp"
                 android:layout_height="100dp"
                 android:layout_margin="16dp"
  
                 android:nestedScrollingEnabled="true"
  
  
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintTop_toBottomOf="@id/googlePayFormView" /&gt;
  
              &lt;View
                  android:layout_width="0dp"
                  android:layout_height="1dp"
                  android:layout_marginTop="16dp"
  
                  app:layout_constraintTop_toBottomOf="@id/recyclerView"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintEnd_toEndOf="parent" /&gt;
  
          &lt;/android.support.constraint.ConstraintLayout&gt;
      &lt;/com.domain.AppName.base.ui.billing.BillingNestedScrollView&gt;
  
      &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>