title: Displaying ConstraintLayout in a DialogFragment
body: <p>I hope you can help me out with a problem. I tried to google it, and looked through the topics here, but was unable to find an answer.</p>
  
  <p>I recently changed my layouts to <code>ConstraintLayouts</code>, and this have been working great so far. My problem however is i had some <code>DialogFragments</code> displaying a <code>LinearLayout</code>, and when i changed it to <code>ConstraintLayout</code> i only shows a faded overlay, but non of the elements in the layout. If i hardcode the width and height to something like <code>100dp</code>, it will display that area. When i try <code>match_parent</code> or any other combination the same problem applies. I also tried setting the height and width to the device height and width but still with no luck.</p>
  
  <p>In the onCreateView in my CreateWeddingMetadataFragment i have:</p>
  
  <pre><code>createButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Log.d(TAG, "Show message dialog");
  
              FragmentManager fm = getFragmentManager();
              CreateWeddingMetadataDialogFragment welcomeMessageDialog = new CreateWeddingMetadataDialogFragment();
              welcomeMessageDialog.show(fm, "metadate_fragment_dialog");
              welcomeMessageDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                  @Override
                  public void onDismiss(DialogInterface dialog) {
                  }
              });
  </code></pre>
  
  <p>In my CreateWeddingMetadataFragmentDialog i have:</p>
  
  <pre><code>public class CreateWeddingMetadataDialogFragment extends DialogFragment{
  
  private static final String TAG = CreateWeddingMetadataDialogFragment.class.getSimpleName();
  
  public Button setupNow, setupLater;
  public TextView mTest;
  public ConstraintLayout parentLayout;
  
  private DialogInterface.OnDismissListener onDismissListener;
  
  
  
  public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
      this.onDismissListener = onDismissListener;
  }
  
  @Override
  public void onDismiss(DialogInterface dialog) {
      super.onDismiss(dialog);
      if (onDismissListener != null) {
          onDismissListener.onDismiss(dialog);
      }
  }
  
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Log.d(TAG, "I was called");
  }
  
  public CreateWeddingMetadataDialogFragment(){}
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.create_welcome_message_view, container);
  
      setupNow = (Button) view.findViewById(R.id.setupNowButton);
      setupLater = (Button) view.findViewById(R.id.setupLaterButton);
      mTest = (TextView) view.findViewById(R.id.welcomeMessageTitle);
      parentLayout = (ConstraintLayout) view.findViewById(R.id.clWelcomeMessage);
  
      DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
      int width = displayMetrics.widthPixels;
      int height = displayMetrics.heightPixels;
  
      parentLayout.setMinimumWidth(width);
      parentLayout.setMinimumHeight(height);
  
      mTest.setText("Test");
      Log.d(TAG, "I was called onCreateView" + mTest);
  
      setupNow.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              //Go to metadate page (Hide this dialog)
          }
      });
  
      setupLater.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              //Go to signin page and create the wedding
          }
      });
  
  
      return view;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>That is with my current try of setting it to the device size.</p>
  
  <p>And here is the create_welcome_message_view:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                           xmlns:app="http://schemas.android.com/apk/res-auto"
                                           android:layout_width="match_parent"
                                           android:layout_height="match_parent"
                                           xmlns:tools="http://schemas.android.com/tools"
                                           android:orientation="vertical"
                                           android:id="@+id/clWelcomeMessage"&gt;
  
  
  
  &lt;Button
      android:text="DET GØR JEG SENERE"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:id="@+id/setupLaterButton"
      app:layout_constraintTop_toTopOf="@+id/guideline19"
      app:layout_constraintBottom_toTopOf="@+id/guideline20"
      android:layout_marginEnd="16dp"
      app:layout_constraintRight_toRightOf="parent"
      android:layout_marginRight="16dp"
      android:layout_marginStart="16dp"
      app:layout_constraintLeft_toLeftOf="parent"
      android:layout_marginLeft="16dp"
      android:background="@drawable/border"
      android:layout_marginTop="2dp"
      android:textColor="@color/colorPrimaryDark"/&gt;
  
  &lt;Button
      android:text="JEG VIL OPSÆTTE DEN NU"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:id="@+id/setupNowButton"
      app:layout_constraintTop_toTopOf="@+id/guideline12"
      app:layout_constraintBottom_toTopOf="@+id/guideline19"
      android:layout_marginEnd="16dp"
      app:layout_constraintRight_toRightOf="parent"
      android:layout_marginRight="16dp"
      android:layout_marginStart="16dp"
      app:layout_constraintLeft_toLeftOf="parent"
      android:layout_marginLeft="16dp"
      android:background="@color/colorPrimaryDark"
      android:layout_marginBottom="2dp"
      android:textColor="@color/White"/&gt;
  
  &lt;TextView
      android:text="EN PERSONLIG VELKOMST"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:id="@+id/welcomeMessageTitle"
      android:layout_marginTop="16dp"
      app:layout_constraintTop_toTopOf="parent"
      android:layout_marginEnd="32dp"
      app:layout_constraintRight_toRightOf="parent"
      android:layout_marginRight="32dp"
      android:layout_marginStart="32dp"
      app:layout_constraintLeft_toLeftOf="parent"
      android:layout_marginLeft="32dp"
      app:layout_constraintBottom_toTopOf="@+id/textView5"
      android:layout_marginBottom="8dp"
      android:textAlignment="center"
      android:textSize="16sp"/&gt;
  
  &lt;TextView
      android:text="Nu skal I definere den velkomst, som jeres gæster får i appen. I kan skrive navnet på brylluppet, en hlsen og har mulighed at vælge et coverbillede"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:id="@+id/textView5"
      app:layout_constraintTop_toTopOf="@+id/guideline14"
      android:layout_marginEnd="32dp"
      app:layout_constraintRight_toRightOf="parent"
      android:layout_marginRight="32dp"
      app:layout_constraintBottom_toTopOf="@+id/textView6"
      android:layout_marginBottom="8dp"
      android:layout_marginStart="32dp"
      app:layout_constraintLeft_toLeftOf="parent"
      android:layout_marginLeft="32dp"
      android:textAlignment="center"/&gt;
  
  &lt;android.support.constraint.Guideline
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/guideline12"
      android:orientation="horizontal"
      tools:layout_editor_absoluteY="204dp"
      tools:layout_editor_absoluteX="0dp"
      app:layout_constraintGuide_percent="0.4"/&gt;
  
  &lt;TextView
      android:text="Du vil altid kunne ændre din opsætning af velkomsten i din brugerprofil."
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:id="@+id/textView6"
      app:layout_constraintBottom_toTopOf="@+id/guideline12"
      android:layout_marginBottom="8dp"
      app:layout_constraintTop_toTopOf="@+id/guideline15"
      android:layout_marginStart="32dp"
      app:layout_constraintLeft_toLeftOf="parent"
      android:layout_marginLeft="32dp"
      android:layout_marginEnd="32dp"
      app:layout_constraintRight_toRightOf="parent"
      android:layout_marginRight="32dp"
      android:textAlignment="center"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintVertical_bias="1.0"/&gt;
  
  &lt;android.support.constraint.Guideline
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/guideline14"
      android:orientation="horizontal"
      tools:layout_editor_absoluteY="51dp"
      tools:layout_editor_absoluteX="0dp"
      app:layout_constraintGuide_percent="0.1"/&gt;
  
  &lt;android.support.constraint.Guideline
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/guideline15"
      android:orientation="horizontal"
      tools:layout_editor_absoluteY="153dp"
      tools:layout_editor_absoluteX="0dp"
      app:layout_constraintGuide_percent="0.3"/&gt;
  
  &lt;android.support.constraint.Guideline
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/guideline19"
      android:orientation="horizontal"
      tools:layout_editor_absoluteY="255dp"
      tools:layout_editor_absoluteX="0dp"
      app:layout_constraintGuide_percent="0.5"/&gt;
  
  &lt;android.support.constraint.Guideline
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/guideline20"
      android:orientation="horizontal"
      tools:layout_editor_absoluteY="305dp"
      tools:layout_editor_absoluteX="0dp"
      app:layout_constraintGuide_percent="0.6"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>If you need any additional information let me know, and thanks in advance.</p>