title: Why does the ScrollView leave a lot of unnecessary space when scrolling down?
body: <p><strong>My content should end on a button. That is, the button is the last bottom element.
  Since there is a lot of text I had to use ScrollView. And when scrolling down, the button goes up and starts to go empty space.
  I tried to set the height of the ScrollView to wrap_content. Nothing has changed.</strong></p>
  <pre><code>&lt;androidx.core.widget.NestedScrollView
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:theme=&quot;@style/ThemeOverlay.Smoke.FullscreenContainer&quot;
      tools:context=&quot;.LectureFragment&quot;
      android:background=&quot;@color/dark_background&quot;&gt;
      
          &lt;LinearLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:orientation=&quot;vertical&quot;
              android:weightSum=&quot;100&quot;&gt;
  
              &lt;ImageView
                  android:id=&quot;@+id/imageView&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;0dp&quot;
                  android:src=&quot;@drawable/day1&quot;
                  android:layout_weight=&quot;20&quot;
                  android:layout_marginEnd=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_marginStart=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_marginBottom=&quot;@dimen/margin_between_something&quot;
                  android:scaleType=&quot;centerInside&quot;
                  /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/textView&quot;
                  android:text=&quot;@string/text&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginEnd=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_marginStart=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_weight=&quot;10&quot;
                  android:textColor=&quot;@color/white&quot; /&gt;
  
              &lt;com.google.android.material.button.MaterialButton
                  android:text=&quot;@string/submit_lecture_rus&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;@dimen/height_button&quot;
                  android:layout_marginEnd=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_marginStart=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:layout_marginBottom=&quot;@dimen/margin_regarding_the_parent&quot;
                  android:backgroundTint=&quot;@color/coral&quot;
                  /&gt;
  
          &lt;/LinearLayout&gt;
  
  &lt;/androidx.core.widget.NestedScrollView&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/61OrL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/61OrL.png" alt="enter image description here" /></a></p>