I would like to ask on how to achieve to wrap a content in alertdialog?
Because the current output of my dialog has an excess white field.

Hope someone can help me to understand this problem thanks.

[![enter image description here](https://i.stack.imgur.com/Me15I.jpg)](https://i.stack.imgur.com/Me15I.jpg)

Here is my activity\_dialog.xml:

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:minWidth="10dp"
    android:minHeight="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:context="com.bloxofcode.toggle.MainActivity">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="50sp"
            android:background="@color/colorHeaderDialog"
            android:textColor="@android:color/white"
            android:text="@string/select_gender"
            android:padding="15dp"
            android:gravity="center_horizontal|left"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="30sp"
            android:padding="15dp"
            android:text="Sample"
            android:id="@+id/editText" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ToggleButton
                android:text="ToggleButton"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/toggleButtonMale"
                android:textOn=""
                android:textOff=""
                android:focusable="false"
                android:background="@drawable/check_male"
                android:layout_weight="1" />

            <ToggleButton
                android:text="ToggleButton"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/toggleButtonFemale"
                android:textOn=""
                android:textOff=""
                android:focusable="false"
                android:background="@drawable/check_male"
                android:layout_weight="1" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="10dp">
            <Button
                android:id="@+id/btnCancel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Cancel"
                android:textSize="20dp"
                android:padding="30dp"
                android:textColor="@android:color/white"
                android:layout_weight="1"/>
            <Button
                android:id="@+id/btnAccept"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Accept"
                android:textSize="20dp"
                android:padding="30dp"
                android:background="@color/colorDialogOK"
                android:textColor="@android:color/white"
                android:layout_weight="1"/>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

```

Here is some of my implementation in the MainActivity.java:

```
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
View mView = getLayoutInflater().inflate(R.layout.activity_dialog, null);
.....
mBuilder.setView(mView);
final AlertDialog dialog = mBuilder.create();
dialog.show();

```