title: Rounded corners for custom AlertDialog
body: <p>I have been updating my apps forgot password functionality from Activity to simple custom Alert Dialog. How should I add rounded corners to Dialog window? I have already read multiple tutorials, but none seem to work in my case. I read from somewhere that I should use setBackgroundResources method somewhere, but I'm not sure where.</p>
  <p><strong>Kotlin code</strong></p>
  <pre><code>// Forgot password textview onClick Listener
      binding.tvForgotPassword.setOnClickListener {
  
          // Inflate add_item_dialog.xml custom view
          val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_forgot_password, null)
  
          // Add AlertDialog Builder
          val dialogBuilder = AlertDialog.Builder(this)
              .setView(dialogView)
  
          // Binding add_item_dialog layout
          val dialogBinding = DialogForgotPasswordBinding.bind(dialogView)
  
          // Show Forgot password Dialog
          val customAlertDialog = dialogBuilder.show()
          dialogBinding.ivCloseDialog.setOnClickListener {
              customAlertDialog.dismiss()
          }
      }
  </code></pre>
  <p><strong>dialog_forgot_password.xml</strong></p>
  <pre><code>&lt;androidx.cardview.widget.CardView
      android:layout_width=&quot;350dp&quot;
      android:layout_height=&quot;500dp&quot;
      app:cardCornerRadius=&quot;20dp&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintHorizontal_bias=&quot;0.5&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;350dp&quot;
          android:layout_height=&quot;500dp&quot;&gt;
  
  
          &lt;ImageView
              android:id=&quot;@+id/iv_closeDialog&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintHorizontal_bias=&quot;0.94&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot;
              app:layout_constraintVertical_bias=&quot;0.060000002&quot;
              app:srcCompat=&quot;@drawable/ic_close&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/tv_forgotPasswordInfo&quot;
              android:layout_width=&quot;250dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;30dp&quot;
              android:gravity=&quot;center&quot;
              android:textSize=&quot;18sp&quot;
              android:text=&quot;@string/enter_email&quot;
              android:textColor=&quot;@color/ColorPrimary&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/tv_forgotPassword&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/submitBtn&quot;
              android:layout_width=&quot;200dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_marginBottom=&quot;20dp&quot;
              android:background=&quot;@drawable/button&quot;
              android:elevation=&quot;4dp&quot;
              android:text=&quot;@string/submit&quot;
              android:textColor=&quot;@color/white&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/emailForgot&quot;
              app:layout_constraintVertical_bias=&quot;1.0&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/tv_forgotPassword&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;36dp&quot;
              android:fontFamily=&quot;sans-serif-black&quot;
              android:text=&quot;@string/forgot_password&quot;
              android:textColor=&quot;@color/ColorPrimary&quot;
              android:textSize=&quot;40sp&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/iv_closeDialog&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/emailForgot&quot;
              android:layout_width=&quot;300dp&quot;
              android:layout_height=&quot;40dp&quot;
              android:background=&quot;@drawable/rounded_edittext&quot;
              android:ems=&quot;10&quot;
              android:hint=&quot;@string/email_address&quot;
              android:importantForAutofill=&quot;no&quot;
              android:inputType=&quot;textEmailAddress&quot;
              android:paddingStart=&quot;15dp&quot;
              android:textColorHint=&quot;@color/ColorPrimary&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/submitBtn&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/tv_forgotPasswordInfo&quot;
              app:layout_constraintVertical_bias=&quot;1.0&quot; /&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;/androidx.cardview.widget.CardView&gt;
  </code></pre>
  <p><strong>Rounded_framelayout.xml</strong></p>
  <pre><code>&lt;solid android:color=&quot;#FFFFFF&quot;/&gt;
  
  
  &lt;padding android:left=&quot;2dp&quot;
      android:top=&quot;2dp&quot;
      android:right=&quot;2dp&quot;
      android:bottom=&quot;2dp&quot;/&gt;
  
  &lt;corners android:radius=&quot;20dp&quot; /&gt;
  </code></pre>