title: Android: Dialog minimum margin
body: <p>I use android <code>android.app.Dialog</code> for create a custom dialog ( for button and background )
  In my Dialog I has a <code>TextView</code>  inside a <code>ScrollView</code> while I has a short text this show perfecly how I want, but if the text is very big my Dialog take the full Screen and I want to has a minimum Margin between dialog and the edge of the screen.</p>
  
  <p>My problem is I want the Dialog to not be bigger then need and I can't set a fix size on this?</p>
  
  <p><code>Here is how this look today.....I what a margin like this</code></p>
  
  <p><img src="https://i.stack.imgur.com/8tX8s.png" alt="How my Dialog is now.">  <img src="https://i.stack.imgur.com/xEQEx.png" alt="I want a margin like this."></p>
  
  <hr>
  
  <p>The <code>GameDialog.java</code></p>
  
  <pre><code>public class GameDialog extends Dialog {
  
      public GameDialog(Context ct, int titleID, int messageID) {
          super(ct, R.style.dialog_style);
          this.setContentView(R.layout.dialog_layout);
  
      }
      // This exist more code but this has noting with the layout to do,only set the text and show the button that exist since the XML file.
  
  }
  </code></pre>
  
  <p>The <code>R.style.dialog_style</code></p>
  
  <pre><code>&lt;style name="dialog_style" parent="@android:style/Theme.Dialog"&gt;
      &lt;item name="android:windowBackground"&gt;?button_image&lt;/item&gt;
      &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
      &lt;item name="android:textColor"&gt;#FF000000&lt;/item&gt;
      &lt;item name="android:textSize"&gt;20sp&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>The <code>R.layout.dialog_layout</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  
  &lt;!-- Dialog layout that show title and a textarea, and under this allow a row of button that is center layout. --&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;LinearLayout android:orientation="vertical" 
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="14px"
                    android:layout_marginRight="14px"&gt;
  
  
          &lt;TextView
              android:layout_gravity="center_vertical"    
              android:id="@+id/text_title"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"&gt;
          &lt;/TextView&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout android:orientation="vertical"    
                    android:layout_width="fill_parent"
                    android:layout_height="0px"
                    android:layout_weight="1"
                    android:layout_marginLeft="14px"
                    android:layout_marginRight="14px"&gt;
  
          &lt;ScrollView 
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
          &gt;
  
              &lt;TextView android:id="@+id/text_main"
                        android:padding="5px"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
              &gt;
              &lt;/TextView&gt;
  
          &lt;/ScrollView&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/layout_button"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:orientation="horizontal"&gt;
              &lt;!-- this will be show while need to show a button --&gt;
          &lt;ImageView
              style="?icon_size.button"
              android:visibility="gone"/&gt;
          &lt;ImageView
              style="?icon_size.button"
              android:visibility="gone"/&gt;
          &lt;ImageView
              style="?icon_size.button"
              android:visibility="gone"/&gt;
          &lt;ImageView
              style="?icon_size.button"
              android:visibility="gone"/&gt;
          &lt;ImageView
              style="?icon_size.button"
              android:visibility="gone"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt; 
  </code></pre>