title: ScrollView in Custom DIalog adds margin to bottom
body: <p>I'm creating a custom dialog with ScrollView inside it due to big amount of elements. </p>
  
  <p>The problem is that ScrollView moves all the content to the top. Seems like it adds margin bottom. Therefore top content is cropped and bot content has too many free space when ScrollView is sliding to bottom. Please see screenshots. </p>
  
  <p>1) When slided to top content is cropped. </p>
  
  <p><a href="https://i.stack.imgur.com/uW79R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uW79R.png" alt="enter image description here"></a></p>
  
  <p>2)When slided to bottom content has margin</p>
  
  <p><a href="https://i.stack.imgur.com/duARS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/duARS.png" alt="enter image description here"></a></p>
  
  <p>That's how it should look like:</p>
  
  <p><a href="https://i.stack.imgur.com/aaNuN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aaNuN.png" alt="enter image description here"></a></p>
  
  <p><strong>Code code:</strong>
  dialog.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/root"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_margin="@dimen/pop_margin_outer"&gt;
  
  &lt;View
      android:id="@+id/view_bg"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/bg_rounded_rectangle"
      android:layout_alignTop="@+id/ll_content"
      android:layout_alignBottom="@id/ll_content"
      android:layout_alignEnd="@id/ll_content"
      android:layout_alignStart="@id/ll_content"
      android:layout_alignLeft="@id/ll_content"
      android:layout_alignRight="@id/ll_content"/&gt;
  
  &lt;include layout="@layout/content_dialog"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginRight="@dimen/activity_vertical_margin"
      android:layout_marginEnd="@dimen/activity_vertical_margin"
      android:layout_marginLeft="@dimen/activity_vertical_margin"
      android:layout_marginStart="@dimen/activity_vertical_margin"
      android:layout_marginBottom="@dimen/activity_horizontal_margin_48"
      android:layout_marginTop="@dimen/activity_horizontal_margin_48"
      android:layout_centerInParent="true"/&gt;
  
  &lt;ImageView
      android:id="@+id/iv_dialog_close"
      android:layout_width="@dimen/btn_x_size"
      android:layout_height="@dimen/btn_x_size"
      android:src="@drawable/ic_x"
      android:layout_above="@id/view_bg"
      android:layout_alignEnd="@id/view_bg"
      android:layout_alignRight="@id/view_bg"
      android:layout_marginTop="@dimen/item_padding_small"
      android:layout_marginRight="@dimen/item_padding_small"
      android:layout_marginEnd="@dimen/item_padding_small"
      android:layout_marginBottom="@dimen/item_padding_small"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Code code:</strong> dialog_content.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/ll_content"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_gravity="center"
  android:gravity="center"
  android:paddingBottom="@dimen/pop_space_vertical_24"
  android:paddingLeft="@dimen/pop_space_vertical_24"
  android:paddingRight="@dimen/pop_space_vertical_24"
  android:paddingTop="@dimen/pop_space_vertical_36"&gt;
  
  
  &lt;ScrollView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:gravity="center"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/tv_headline"
              style="@style/yellow_text_middle"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentTop="true"
              android:layout_marginBottom="@dimen/pop_space_vertical_24"
              android:text="@string/db_headline"
              android:textSize="@dimen/middle_text_min" /&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:orientation="horizontal"&gt;
  
              &lt;TextView
                  style="@style/yellow_text_small"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:gravity="center"
                  android:text="@string/db_content_1" /&gt;
  
              &lt;TextView
                  android:id="@+id/tv_app_name"
                  style="@style/yellow_text_small"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:gravity="center"
                  android:text="@string/app_name"
                  android:textSize="@dimen/middle_text_min" /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;TextView
              style="@style/yellow_text_small"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_marginBottom="@dimen/pop_space_vertical_24"
              android:gravity="center"
              android:text="@string/db_content_2" /&gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="@dimen/small_logo"
              android:layout_marginBottom="@dimen/pop_space_vertical_24"
              android:src="@drawable/ic_logo" /&gt;
  
          &lt;TextView
              style="@style/teal_text_small"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_marginBottom="@dimen/pop_space_vertical_24"
              android:gravity="center"
              android:text="@string/db_content_3" /&gt;
  
          &lt;include layout="@layout/content_broker_input" /&gt;
  
          &lt;Button
              android:id="@+id/btn_continue"
              style="@style/btn_bg_yellow"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:layout_marginBottom="@dimen/pop_space_vertical_24"
              android:text="@string/db_btn_continue" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Any ideas why ScrollView has this behavior?</strong></p>