title: Custom FragmentDialog with round corners and not 100% screen width
body: <p>I am creating a custom fragment dialog with round corners and with layout that would not fill the screen width (I would prefer if it just wrapped its content).</p>
  
  <p>this is my <code>rounded_dialog.xml</code> in drawable folder, which is called by my Custom <code>ThemeWithCorners</code> as a background for the dialog. I also tried to set it as background to the linear layout which creates its content but nothing works.</p>
  
  <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle" 
  &gt;
  &lt;solid android:color="@android:color/white"/&gt;
  &lt;corners android:radius="20dp"
  /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>and this is how i call the dialog:</p>
  
  <pre><code>final String FTAG = "TAG_FRAGMENT_DIALOG_CALENDAR";
      dialog = (CalendarDialog) fm.findFragmentByTag(FTAG);
      ft = fm.beginTransaction();
      if (dialog != null)
      {
          ft.remove(dialog);
      }
      dialog = CalendarDialog.newInstance(this);      
      dialog.setCancelable(true);
  
      ft.add(dialog, FTAG);
      ft.show(dialog);
      ft.commit();
  </code></pre>
  
  <p>In onCreate method of the dialog I set the style and theme:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setStyle(DialogFragment.STYLE_NO_TITLE, R.style.ThemeWithCorners);      
  }
  </code></pre>
  
  <p>This is the onCreateView method:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  getDialog().setCanceledOnTouchOutside(true);
  v = (MyCalendar)inflater.inflate(R.layout.calendar_dialog, container, true)
      return v;
  }
  </code></pre>
  
  <p>I also tried to add this to onCreateDialog method as other answers on SO suggested but did not work either:</p>
  
  <pre><code>@Override
  public Dialog onCreateDialog(Bundle savedInstanceState)
  {
      Dialog d =  super.onCreateDialog(savedInstanceState);
      LayoutParams lp=d.getWindow().getAttributes();
      d.getWindow().setBackgroundDrawable(new ColorDrawable(0));
      lp.width=-2;lp.height=-2;lp.gravity=Gravity.CENTER;
      lp.dimAmount=0;            
      lp.flags=LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_NOT_TOUCH_MODAL;
  
      return d;
  }
  </code></pre>
  
  <p>So to sum it up, I want round corners, not 100% width of the screen, it preferably should wrap its content. Please, please, I need some help, I am really desperate about this, I´v ebeen trying it for days!</p>