title: How to set Dialog width and height in percents in XML
body: <p>I need my Dialog width and height fill 70% of screen space. I'm using <code>ConstraintLayout</code> as root layout and tried to achieve this by using <code>app:layout_constraintWidth_percent</code> but it's not working.</p>
  <p>It would be great to achieve this in <code>XML</code> without Java code.</p>
  <p>Here is my code:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_gravity=&quot;center&quot;
      android:background=&quot;@drawable/dialog_background_shape&quot;
      android:padding=&quot;@dimen/app_padding&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textView13&quot;
          style=&quot;@style/text_plain3&quot;
          android:textStyle=&quot;bold&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;0dp&quot;
          android:layout_marginTop=&quot;0dp&quot;
          android:text=&quot;@string/add_member_title&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/button_add_member_close&quot;
          style=&quot;@style/text_title2&quot;
          android:textStyle=&quot;bold&quot;
          android:layout_width=&quot;28dp&quot;
          android:layout_height=&quot;28dp&quot;
          android:background=&quot;@drawable/button_dialog_close&quot;
          android:gravity=&quot;center&quot;
          android:text=&quot;X&quot;
          android:textColor=&quot;@color/text_plain3&quot;
          android:textSize=&quot;20sp&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          tools:ignore=&quot;HardcodedText&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/add_member_group_id&quot;
          style=&quot;@style/text_group_id&quot;
          android:layout_width=&quot;250dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;32dp&quot;
          android:layout_marginTop=&quot;64dp&quot;
          android:layout_marginEnd=&quot;32dp&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/textView13&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textView17&quot;
          style=&quot;@style/text_card&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;8dp&quot;
          android:text=&quot;@string/add_member_annotation&quot;
          app:layout_constraintStart_toStartOf=&quot;@+id/add_member_group_id&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/add_member_group_id&quot;/&gt;
  
      &lt;EditText
          android:id=&quot;@+id/add_member_user_id&quot;
          android:layout_width=&quot;248dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;8dp&quot;
          android:ems=&quot;10&quot;
          android:hint=&quot;@string/add_member_hint_id&quot;
          android:importantForAutofill=&quot;no&quot;
          android:inputType=&quot;textPersonName&quot;
          android:maxLength=&quot;28&quot;
          app:layout_constraintEnd_toEndOf=&quot;@+id/add_member_group_id&quot;
          app:layout_constraintStart_toStartOf=&quot;@+id/add_member_group_id&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/textView17&quot; /&gt;
  
      &lt;Button
          android:id=&quot;@+id/button_add_member&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;48dp&quot;
          android:layout_marginBottom=&quot;48dp&quot;
          android:text=&quot;@string/add_member_button_add&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;@+id/add_member_group_id&quot;
          app:layout_constraintStart_toStartOf=&quot;@+id/add_member_group_id&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/add_member_user_id&quot;/&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>