title: Dialog Fragment with wrap_content coming as a full screen. How to make it as a height of layout and not a full screen?
body: <p>I have created a custom dialog fragment and its xml as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5dp"
  
      android:padding="5dip" &gt;
  
      &lt;ListView
          android:id="@+id/product_list"
           android:background="@drawable/border_details"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
           /&gt;
  
      &lt;RelativeLayout
          android:id="@+id/AddtoCart"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_marginTop="10dp"
  
          android:background="#005959" &gt;
  
          &lt;Button
              android:id="@+id/button_addToCart"
              android:layout_width="250dp"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true"
              android:background="@drawable/gradient_button"
              android:layout_marginTop="2dp"
              android:layout_marginBottom="2dp"
              android:text="@string/add_to_cart"
              android:textColor="#000000" /&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>When I call this Dialog, it is taking full screen as provided in the screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/Kwhjt.png" alt="ScreenShot"></p>
  
  <p>How do I restrict the size of this Dialog to the height of the list and the button?</p>
  
  <p>How do I remove the excess white space?</p>