title: Android dialog wrap_content not working
body: <p>I have a <strong>custom dialog</strong> set up and I have the layout's width set to <code>wrap_content</code> but it is still taking the entire screen width. I even tried setting the width to <strong>100dp</strong> and it still uses the whole screen Why does this happen? </p>
  
  <blockquote>
    <p>I have set up the dialog like this:</p>
  </blockquote>
  
  <pre><code>public class DialogGoToLine extends Dialog
  {
  //The root view of the dialog
  private static View rootView;
  
  public DialogGoToLine(Context context, int themeResId){
      super(context, themeResId);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
  
      //Allow the dialog to be canceled by tapping out of its bounds
      setCancelable(true);
  
      //Inflate the custom layout
      LayoutInflater layoutInflater = LayoutInflater.from(HotspotHelper.getAppContext());
      rootView = layoutInflater.inflate(R.layout.dialog_go_to_line, null);
  
      //Set up the layout
      //setTitle(HotspotHelper.getAppContext().getString(R.string.clientDetails));
      //setTitle("Go to line");
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(rootView);
  
      final EditText editText = (EditText) rootView.findViewById(R.id.editTextGoToLine);
  
      Button buttonGoToLine = (Button) rootView.findViewById(R.id.buttonGoToLine);
      buttonGoToLine.setOnClickListener(new View.OnClickListener(){
  
              @Override
              public void onClick(View p1)
              {
                  int line = Integer.valueOf(editText.getText().toString()) - 1;
                  ((LinearLayoutManager)LogActivity.recyclerViewLog.getLayoutManager()).scrollToPositionWithOffset(line, (int)HotspotHelper.dpToPx(30));
                  dismiss();
              }
      });
  }
  }
  </code></pre>
  
  <blockquote>
    <p>And the layout XML:</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="100dp"
  android:layout_height="wrap_content"
  android:background="@color/colorPrimary"
  android:gravity="center_vertical"
  android:orientation="horizontal"&gt;
  
  &lt;TextView
      android:id="@+id/textViewGoToLabel"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="4dp"
      android:labelFor="@+id/editTextGoToLine"
      android:text="Go to line: "
      android:background="@color/accent"
      android:textColor="@color/primaryText"
      android:textSize="18sp"/&gt;
  
  &lt;EditText
      android:id="@id/editTextGoToLine"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:singleLine="true"
      android:layout_margin="4dp"
      android:layout_centerVertical="true"
      android:inputType="number"
      android:gravity="center"
      android:textSize="18sp"/&gt;
  
  &lt;Button
      android:id="@+id/buttonGoToLine"
      android:layout_width="wrap_content"
      android:text="Go"
      android:layout_margin="4dp"
      android:textSize="18sp"
      android:layout_height="wrap_content"/&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Edit 1</strong>
  If it makes a difference, this dialog has a style in which I declared the background to this drawable:</p>
  
  <p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt;
      &lt;solid android:color="@color/colorPrimary"/&gt;
      &lt;corners
          android:radius="2dp" /&gt;
  &lt;/shape&gt;</code></p>