title: android custom dialog view not fit in the dialog layout
body: <p>I create a alertdialog dynamically, it seems okay except that there are some space between the top of dialog view and the top of dialog layout margin. Check the pic would be more clear.</p>
  
  <p><a href="https://i.stack.imgur.com/flTbi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/flTbi.png" alt="dialog layout margin problem"></a></p>
  
  <p>Is there some problem when I inflate the view? I just google it, but I cannot find any clues. Please help to modify the layout.</p>
  
  <p>The dialog.xml is as following</p>
  
  <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="wrap_content"
      android:layout_height="wrap_content"
      android:background="@color/white"
      android:orientation="vertical"&gt;
      &lt;TextView
          android:id="@+id/dialog_title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/hello"
          android:textSize="20sp"
          android:background="@color/light_blue"
          android:gravity="center"
          android:paddingLeft="15sp"
          android:paddingRight="15sp"
          android:paddingTop="5sp"
          android:paddingBottom="5sp"
          android:textColor="@color/white"
          /&gt;
      &lt;TextView
          android:id="@+id/dialog_msg"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:text="@string/hello"
          android:textSize="17sp"
          android:paddingTop="15sp"
          android:paddingBottom="10sp"
          android:textColor="@color/black"
          /&gt;
      &lt;Button
          android:id="@+id/dialog_button"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:layout_centerInParent="true"
          android:text="@string/Ok"
          android:textColor="@color/light_blue"
          android:textSize="18sp"
          android:background="@color/white"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And the code I dynamic create dialog</p>
  
  <pre><code>private AlertDialog createDialog(String title, String msg){
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      //AlertDialog dialog = builder.create();
  
      LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
          (Context.LAYOUT_INFLATER_SERVICE);
      View dialogView = inflater.inflate(R.layout.dialog, null);
      ((TextView)dialogView.findViewById(R.id.dialog_title)).setText(title);
      ((TextView)dialogView.findViewById(R.id.dialog_msg)).setText(msg);
      builder.setView(dialogView);
      final AlertDialog dialog = builder.create();
      ((Button)dialogView.findViewById(R.id.dialog_button)).setOnClickListener(new OnClickListener(){
          public void onClick(View v){
              dialog.dismiss();
          }
      });
      return dialog;
  }
  </code></pre>