title: AlertDialog won't wrap content no matter what I try
body: <p>Here is my xml file for my dialog</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="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/main"
  android:paddingTop="23dp"
  android:background="@android:color/white"&gt;
  
  &lt;ImageView
      android:id="@+id/officer"
      android:layout_width="47dp"
      android:layout_height="47dp"
      android:layout_marginLeft="24dp"
      android:background="@drawable/officerman"/&gt;
  &lt;TextView
      android:id="@+id/text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Are you sure you want\nto sign out?"
      android:textSize="15.5dp"
      android:textColor="#1C86FF"
      android:layout_marginTop="4dp"
      android:lineSpacingExtra="2dp"
      android:layout_marginLeft="84dp"/&gt;
  
  &lt;LinearLayout
      android:layout_marginTop="20dp"
      android:layout_width="264dp"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:weightSum="1"
      android:layout_below="@id/officer"&gt;
  
      &lt;Button
          android:id="@+id/yes"
          android:layout_width="wrap_content"
          android:layout_weight="0.5"
          android:layout_height="42dp"
          android:background="#1C86FF"
          android:text="Yes"
          android:textAllCaps="false"
          android:textSize="15dp"
          android:textColor="@android:color/white"/&gt;
  
      &lt;Button
          android:id="@+id/no"
          android:layout_width="wrap_content"
          android:layout_weight="0.5"
          android:layout_height="42dp"
          android:background="#0078FF"
          android:textSize="15dp"
          android:textColor="@android:color/white"
          android:textAllCaps="false"
          android:text="No"/&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Here is my java code</strong></p>
  
  <pre><code>    AlertDialog.Builder build = new AlertDialog.Builder(Login.this);
      View lview = getLayoutInflater().inflate(R.layout.dialog_leave,null);
      build.setView(lview);
      AlertDialog dialog = build.create();
      dialog.show();
  </code></pre>
  
  <p>The <code>alertdialog</code> size isn't wrapping to my content no matter what I try. It ends up like this. It adds extended space to the right to get it to a certain size.</p>
  
  <p><a href="https://i.stack.imgur.com/D9V4V.png" rel="noreferrer">Click on this to see the image. It adds extended space to the right see to get it to the default alertdialog size</a></p>
  
  <p>I have tried using <code>getWindow.setLayout(width,height)</code> in pixels, but that is too much of a pain, there must be a better way of doing it. </p>
  
  <p>I tried <code>getWindow.setLayout(Relative.LayoutParams.WRAP_CONTENT, ...)</code> also, and the same thing still happens. </p>
  
  <p>I have also tried using <code>popupwindow</code>. What is the easy fix to this issue?</p>