title: Adjusting DialogFragment Width and Height
body: <p>I have problem with <code>DialogFragmnt</code>'s <code>Width</code> and <code>Height</code>. Here is my class representing <code>DialogFragmetn</code>:</p>
  
  <pre><code>public class RecipeAddDialogFragment extends DialogFragment {
  
      private ArrayList&lt;RecipeDialogItem&gt; recipeDialogItems;
      private RecipeAddDialogAdapter recipeDialogAdapter;
      private String recipeUniqueId;
      private CoordinatorLayout coordinatorLayout;
      private RecipeAddDialogFragment recipeDialogFragment;
  
      @Override
      public void onStart() {
          super.onStart();
          if (getDialog() == null) {
              return;
          }
  
          int dialogWidth = 600;
          int dialogHeight = 300;
          getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
          getDialog().setTitle(getString(R.string.recipe_dialog_title));
      }
  
      @Override
      public void onCreate(Bundle bundle) {
          super.onCreate(bundle);
          setStyle(DialogFragment.STYLE_NORMAL, R.style.AppTheme_DialogFragment);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          return inflater.inflate(R.layout.dialog_fragment, container, false);
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          recipeDialogItems = new ArrayList&lt;&gt;();
          RecyclerView dialogRecyclerView = (RecyclerView) view.findViewById(
                  R.id.dialog_recycler_view);
  
          recipeDialogAdapter = new RecipeAddDialogAdapter(getContext(), recipeDialogItems,
                  R.layout.recipe_dialog_item);
          recipeDialogAdapter.setRuidClRdf(recipeUniqueId, coordinatorLayout, recipeDialogFragment);
  
          dialogRecyclerView.setHasFixedSize(true);
          dialogRecyclerView.setAdapter(recipeDialogAdapter);
          dialogRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          fillRecipeDialogArray();
      }
  
      private void fillRecipeDialogArray() {
          String name = getString(R.string.add_to_favourites);
          int icon = R.drawable.ic_heart_48dp;;
  
          RecipeDialogItem dialogItem = new RecipeDialogItem();
          dialogItem.setRowIcon(icon);
          dialogItem.setRowOption(name);
          recipeDialogItems.add(dialogItem);
  
          recipeDialogAdapter.notifyDataSetChanged();
      }
  
      public void setReferences(String recipeUniqueId, CoordinatorLayout coordinatorLayout,
                                RecipeAddDialogFragment recipeDialogFragment) {
          this.recipeUniqueId = recipeUniqueId;
          this.coordinatorLayout = coordinatorLayout;
          this.recipeDialogFragment = recipeDialogFragment;
      }
  }
  </code></pre>
  
  <p>Here is <code>.xml</code> which I infalte in this <code>DialogFragment</code>:</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="match_parent"
      android:layout_height="match_parent"
      android:gravity="center|left"
      android:padding="16dp"
      android:orientation="horizontal"
      android:clickable="true"
      android:background="?android:attr/selectableItemBackground"&gt;
  
      &lt;!-- Option Icon --&gt;
      &lt;ImageView
          android:id="@+id/recipe_dialog_option_icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginRight="4dp"
          android:tint="@color/primary" /&gt;
  
      &lt;!-- Text Option --&gt;
      &lt;TextView
          android:id="@+id/recipe_dialog_option_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="18sp"
          android:textColor="@color/primary_text" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The problem is that when I set it's size to 600 x 300 it is displayed fine in my 1280x720 device, but for example when my friend displays it on 1920x1080 resolution dialog is wrapped and only title is shown. List is wrapped and is not entire shown. Any idea how can I automaticly set it's size to fit every display and show entire dialog which is wrapped to it's content?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I have figured out to adjust the width of the <code>DialogFragment</code> to it's content like this:</p>
  
  <pre><code>getDialog().getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT,
              WindowManager.LayoutParams.WRAP_CONTENT);
      getDialog().setTitle(getString(R.string.recipe_dialog_title));
  </code></pre>
  
  <p>However height is not working properly :/</p>