title: Set custom width and height for DialogFragment
body: <p>I had a DialogFragment with TableLayout inside. When I executed my code the DialogFragment height occupied my whole screen. I am using RelativeLayout.  Can anyone help me to set custom width and height of a DialogFragment in Android? This is what I have done, but won't work for me:</p>
  
  <pre><code>Window view_dialog = getDialog().getWindow();
          view_dialog.setTitle("MODE :  CONNECTION");
          view_dialog.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
          WindowManager.LayoutParams parameters = view_dialog.getAttributes();
          parameters.y = dptopx(60);
          view_dialog.setAttributes(parameters);
  
  
  private int dptopx(int i) {
          DisplayMetrics measurements = getActivity().getResources().getDisplayMetrics();
          return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, i, measurements);
      }
  </code></pre>