title: Problem in using NestedScrollView in Constraint layout
body: <p>I am using Constraint layout inside the NestestScrollView as shown below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;androidx.constraintlayout.widget.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/clProfileFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;androidx.appcompat.widget.AppCompatImageView
      android:id="@+id/appCompatImageView8"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:scaleType="centerCrop"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHeight_percent="0.7"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:srcCompat="@mipmap/bg_nature" /&gt;
  
  
  &lt;de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/ivProfileFragment"
      android:layout_width="30dp"
      android:layout_height="30dp"
      android:layout_marginStart="16dp"
      android:layout_marginTop="16dp"
      android:src="@drawable/ic_profile"
      android:visibility="visible"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;TextView
      android:id="@+id/tvUserName"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="16dp"
      android:fontFamily="@font/raleway_medium"
      android:letterSpacing="0.2"
      android:textAlignment="center"
      android:textColor="@color/darkBlue"
      app:layout_constraintBottom_toBottomOf="@+id/ivProfileFragment"
      app:layout_constraintStart_toEndOf="@+id/ivProfileFragment"
      app:layout_constraintTop_toTopOf="@+id/ivProfileFragment"
      tools:text="Mehul Kanzriya" /&gt;
  
  
  &lt;androidx.appcompat.widget.AppCompatImageView
      android:id="@+id/ivCloseProfileFragment"
      style="@style/VectorImageView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="start"
      android:layout_marginTop="16dp"
      android:layout_marginEnd="16dp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:srcCompat="@drawable/ic_close" /&gt;
  
  &lt;androidx.core.widget.NestedScrollView
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:fillViewport="true"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/ivProfileFragment"
      app:layout_constraintBottom_toTopOf="@id/button"&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"&gt;
  
          &lt;TextView
              android:id="@+id/textView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginStart="8dp"
              android:layout_marginTop="32dp"
              android:layout_marginEnd="8dp"
              android:fontFamily="@font/raleway_semibold"
              android:letterSpacing="0.3"
              android:text="@string/text_subscribe"
              android:textColor="@color/darkBlue"
              android:textSize="18sp"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent" /&gt;
  
          &lt;TextView
              android:id="@+id/textView2"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginStart="16dp"
              android:layout_marginTop="16dp"
              android:layout_marginEnd="16dp"
              android:letterSpacing="0.3"
              android:text="@string/text_subscription_feature_1"
              android:textAlignment="center"
              android:textColor="@color/subscriptionFeaturesColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@+id/textView" /&gt;
  
          &lt;TextView
              android:id="@+id/textView4"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginTop="8dp"
              android:letterSpacing="0.3"
              android:text="@string/text_subscription_feature_2"
              android:textAlignment="center"
              android:textColor="@color/subscriptionFeaturesColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintEnd_toEndOf="@+id/textView2"
              app:layout_constraintStart_toStartOf="@+id/textView2"
              app:layout_constraintTop_toBottomOf="@+id/textView2" /&gt;
  
          &lt;TextView
              android:id="@+id/textView5"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginTop="8dp"
              android:letterSpacing="0.3"
              android:text="@string/text_subscription_feature_3"
              android:textAlignment="center"
              android:textColor="@color/subscriptionFeaturesColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintEnd_toEndOf="@+id/textView4"
              app:layout_constraintStart_toStartOf="@+id/textView4"
              app:layout_constraintTop_toBottomOf="@+id/textView4" /&gt;
  
          &lt;androidx.appcompat.widget.AppCompatImageView
              android:id="@+id/appCompatImageView2"
              android:layout_width="350dp"
              android:layout_height="168dp"
              android:layout_marginTop="32dp"
              app:layout_constraintEnd_toEndOf="@+id/textView5"
              app:layout_constraintStart_toStartOf="@+id/textView5"
              app:layout_constraintTop_toBottomOf="@+id/textView5"
              app:srcCompat="@mipmap/bg_pdf_resting" /&gt;
  
          &lt;com.google.android.material.card.MaterialCardView
              android:id="@+id/cvAnnualPlan"
              android:layout_width="150dp"
              android:layout_height="wrap_content"
              android:layout_marginStart="16dp"
              android:layout_marginTop="16dp"
              app:cardBackgroundColor="@android:color/transparent"
              app:cardCornerRadius="14dp"
              app:cardElevation="0dp"
              app:layout_constraintEnd_toStartOf="@+id/cvMonthlyPlan"
              app:layout_constraintHorizontal_chainStyle="spread"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@+id/appCompatImageView2"
              app:strokeColor="@color/darkBlue"
              app:strokeWidth="3dp"&gt;
  
              &lt;com.google.android.material.card.MaterialCardView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="2dp"
                  app:cardBackgroundColor="@color/subscriptionCardBackgroundColor"
                  app:cardCornerRadius="12dp"
                  app:cardElevation="0dp"&gt;
  
                  &lt;androidx.constraintlayout.widget.ConstraintLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"&gt;
  
  
                      &lt;TextView
                          android:id="@+id/textView7"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:background="@color/darkBlue"
                          android:fontFamily="@font/raleway_medium"
                          android:letterSpacing="0.1"
                          android:padding="8dp"
                          android:text="@string/text_subscription_most_popular"
                          android:textAlignment="center"
                          android:textColor="@android:color/white"
                          android:textSize="12sp"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toTopOf="parent" /&gt;
  
                      &lt;TextView
                          android:id="@+id/textView3"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="32dp"
                          android:layout_marginEnd="8dp"
                          android:fontFamily="@font/raleway_semibold"
                          android:letterSpacing="0.3"
                          android:text="ANNUAL"
                          android:textColor="@color/lightYellow"
                          android:textSize="@dimen/subscriptionPlanTitle"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView7" /&gt;
  
                      &lt;TextView
                          android:id="@+id/textView6"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="16dp"
                          android:layout_marginEnd="8dp"
                          android:fontFamily="@font/roboto_bold"
                          android:text="Rs 60.00"
                          android:textColor="@android:color/white"
                          android:textSize="@dimen/subscriptionPlanPrice"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView3" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="8dp"
                          android:layout_marginBottom="32dp"
                          android:fontFamily="@font/raleway_semibold"
                          android:letterSpacing="0.3"
                          android:text="@string/text_per_month"
                          android:textColor="@android:color/white"
                          android:textSize="@dimen/subscriptionPlanMonthly"
                          app:layout_constraintBottom_toBottomOf="parent"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView6" /&gt;
  
                  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
              &lt;/com.google.android.material.card.MaterialCardView&gt;
          &lt;/com.google.android.material.card.MaterialCardView&gt;
  
          &lt;com.google.android.material.card.MaterialCardView
              android:id="@+id/cvMonthlyPlan"
              android:layout_width="150dp"
              android:layout_height="wrap_content"
              android:layout_marginStart="8dp"
              android:layout_marginEnd="8dp"
              app:cardBackgroundColor="@android:color/transparent"
              app:cardCornerRadius="14dp"
              app:cardElevation="0dp"
              app:layout_constraintBottom_toBottomOf="@+id/cvAnnualPlan"
              app:layout_constraintEnd_toEndOf="parent"
  
              app:layout_constraintStart_toEndOf="@+id/cvAnnualPlan"
              app:layout_constraintTop_toTopOf="@+id/cvAnnualPlan"
              app:strokeColor="@color/darkBlue"
              app:strokeWidth="3dp"&gt;
  
              &lt;com.google.android.material.card.MaterialCardView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="2dp"
                  app:cardBackgroundColor="@color/subscriptionCardBackgroundColor"
                  app:cardCornerRadius="12dp"
                  app:cardElevation="0dp"&gt;
  
                  &lt;androidx.constraintlayout.widget.ConstraintLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"&gt;
  
  
                      &lt;TextView
                          android:id="@+id/textView8"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:padding="8dp"
                          android:textSize="12sp"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toTopOf="parent" /&gt;
  
                      &lt;TextView
                          android:id="@+id/textView44"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="32dp"
                          android:layout_marginEnd="8dp"
                          android:fontFamily="@font/raleway_semibold"
                          android:letterSpacing="0.3"
                          android:text="MONTHLY"
                          android:textColor="@color/lightYellow"
                          android:textSize="@dimen/subscriptionPlanTitle"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView8" /&gt;
  
                      &lt;TextView
                          android:id="@+id/textView66"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="16dp"
                          android:layout_marginEnd="8dp"
                          android:fontFamily="@font/roboto_bold"
                          android:text="Rs 70.00"
                          android:textColor="@android:color/white"
                          android:textSize="@dimen/subscriptionPlanPrice"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView44" /&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="8dp"
                          android:layout_marginBottom="32dp"
                          android:fontFamily="@font/raleway_semibold"
                          android:letterSpacing="0.3"
                          android:text="@string/text_per_month"
                          android:textColor="@android:color/white"
                          android:textSize="@dimen/subscriptionPlanMonthly"
                          app:layout_constraintBottom_toBottomOf="parent"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toBottomOf="@+id/textView66" /&gt;
  
                  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
              &lt;/com.google.android.material.card.MaterialCardView&gt;
          &lt;/com.google.android.material.card.MaterialCardView&gt;
  
          &lt;TextView
              android:id="@+id/textView9"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginStart="8dp"
              android:layout_marginTop="16dp"
              android:layout_marginEnd="8dp"
              android:letterSpacing="0.3"
              android:text="@string/text_subscription_feature_4"
              android:textAlignment="center"
              android:textColor="@color/subscriptionFeaturesColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@+id/cvAnnualPlan" /&gt;
  
          &lt;TextView
              android:id="@+id/textView10"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginTop="8dp"
              android:letterSpacing="0.3"
              android:text="@string/text_subscription_feature_5"
              android:textAlignment="center"
              android:textColor="@color/subscriptionFeaturesColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintEnd_toEndOf="@+id/textView9"
              app:layout_constraintStart_toStartOf="@+id/textView9"
              app:layout_constraintTop_toBottomOf="@+id/textView9" /&gt;
  
          &lt;TextView
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginStart="8dp"
              android:layout_marginTop="8dp"
              android:layout_marginBottom="16dp"
              android:fontFamily="@font/raleway_semibold"
              android:letterSpacing="0.3"
              android:text="@string/button_logout"
              android:textAlignment="center"
              android:textColor="@color/logoutButtonColor"
              android:textSize="@dimen/subscriptionFeaturesSize"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="@+id/textView10"
              app:layout_constraintStart_toStartOf="@+id/textView10"
              app:layout_constraintTop_toBottomOf="@+id/textView10" /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/androidx.core.widget.NestedScrollView&gt;
  
  &lt;Button
      android:id="@+id/button"
      style="@style/UnelevatedButton"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:text="@string/button_subscribe"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent" /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>The problem is that the first two TextViews are getting cropped and an unnecessary padding is added at the bottom of the NestedScrollView.</p>
  
  <p>A <a href="https://github.com/googlecodelabs/constraint-layout/issues/43" rel="noreferrer">similar bug</a> was filed a few months before but I think it's not solved yet. </p>
  
  <p>Similar questions have been asked before, but I can't find the proper solution to it.</p>