Remove unnecessary margins from a custom dialog
<p>I have a problem that I am designing a custom dialog for this. I am creating a xml for this as Framelayout is the root layout, and another framelayout with a gray background image is used for the contents, in which I have added a textview and two buttons Ok and Cancel and use all of this through <code>dialog.setContentView(desired Xml Resource);</code><br>
But when I generate that particular dialog then it shows extra spaces from each side, or we can say that extra margins are there but I don't know how it will removed? Please review the image attached with this question and suggest me the right solution.</p>

<p><strong>Xml Layout:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt;

    &lt;FrameLayout android:id="@+id/rel"
        android:layout_gravity="center_vertical" android:background="@drawable/dialog_box_bg" android:layout_width="wrap_content" android:layout_height="189dp"&gt;
        &lt;TextView android:id="@+id/tv_LogoutDialog_Text"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:textColor="#424242"
            android:text="Are you sure want to logout?" android:textSize="20dip" android:layout_gravity="center_vertical|center_horizontal"&gt;&lt;/TextView&gt;
        &lt;Button android:id="@+id/btn_LogoutDialog_Cancel" android:background="@drawable/dialog_cancel_btn"
            android:layout_marginLeft="20dip" android:layout_width="120dip" android:layout_height="42dip" android:layout_gravity="bottom|left" android:layout_marginBottom="15dip"&gt;&lt;/Button&gt;
        &lt;Button android:id="@+id/btn_LogoutDialog_Ok"
    android:background="@drawable/dialog_ok_btn_hover"
    android:layout_width="120dip"
    android:layout_height="42dip" android:layout_marginLeft="180dip" android:layout_gravity="bottom|right" android:layout_marginBottom="15dip" android:layout_marginRight="20dip"&gt;&lt;/Button&gt;
    &lt;/FrameLayout&gt;
&lt;/FrameLayout&gt;
</code></pre>

<p><strong>Code:</strong></p>

<pre><code>@Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case 0:
            dialog = new Dialog(HomeScreenActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.logoutdialog);
            btn_cancel = (Button)dialog.findViewById(R.id.btn_LogoutDialog_Cancel);
            btn_ok = (Button)dialog.findViewById(R.id.btn_LogoutDialog_Ok);

            btn_cancel.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    dismissDialog(0);

                }
            });

            btn_logout.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    Intent intent = new Intent(HomeScreenActivity.this,LoginScreen.class);
                    startActivity(intent);

                }
            });
        return dialog;
        }
        return null;
    }
</code></pre>

<p>Thanks in advance.<img src="http://i.stack.imgur.com/YxdQS.png" alt="enter image description here"></p>
