title: How to make background of dialog box transparent in Android?
body: <p>I want to make a custom dialog box, this box is like rating &amp; review box, in which I have to show image and half of its background should be invisible. Image should be appear like its half is out of the box.
  I am unable to get it.</p>
  <p>My sample code is:</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;
      android:background=&quot;@color/transparent&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:id=&quot;@+id/imageOuterLayout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:background=&quot;@color/transparent&quot;
          android:layout_height=&quot;100dp&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/ratingMainLayout&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/upperImageLayout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;50dp&quot;
              android:background=&quot;@color/transparent&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/lowerImageLayout&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/lowerImageLayout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;50dp&quot;
              android:background=&quot;@color/white&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/upperImageLayout&quot;/&gt;
  
          &lt;com.mikhaellopez.circularimageview.CircularImageView
              android:layout_width=&quot;100dp&quot;
              android:layout_height=&quot;100dp&quot;
              android:background=&quot;@drawable/person_calling_img&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/closeRating&quot;
              android:visibility=&quot;gone&quot;
              android:layout_width=&quot;25dp&quot;
              android:layout_height=&quot;25dp&quot;
              android:layout_marginRight=&quot;5dp&quot;
              android:layout_marginTop=&quot;5dp&quot;
              android:background=&quot;@drawable/ic_close&quot;
              app:layout_constraintRight_toRightOf=&quot;@+id/upperImageLayout&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/upperImageLayout&quot; /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:id=&quot;@+id/ratingMainLayout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:background=&quot;@color/white&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/imageOuterLayout&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/taskerNameRating&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:padding=&quot;12dp&quot;
              android:text=&quot;@string/anonymous&quot;
              android:textColor=&quot;@color/black&quot;
              android:textSize=&quot;16sp&quot;
              android:textStyle=&quot;bold&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/taskRatingBar&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;RatingBar
              android:id=&quot;@+id/taskRatingBar&quot;
              style=&quot;@style/ratingBar&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:numStars=&quot;5&quot;
              android:scaleX=&quot;0.8&quot;
              android:scaleY=&quot;0.8&quot;
              android:stepSize=&quot;1&quot;
              android:theme=&quot;@style/ratingBar&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@id/taskerNameRating&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/taskRatingHeading&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:gravity=&quot;center&quot;
              android:fontFamily=&quot;@font/axiforma_medium&quot;
              android:text=&quot;@string/task_rating_heading&quot;
              android:textColor=&quot;#333333&quot;
              android:textSize=&quot;17sp&quot;
              app:layout_constraintLeft_toLeftOf=&quot;@+id/taskRatingBar&quot;
              app:layout_constraintRight_toRightOf=&quot;@+id/taskRatingBar&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/taskRatingBar&quot; /&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/reviewRowOneLayout&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;12dp&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/reviewRowTwoLayout&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/taskRatingHeading&quot;&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt1&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Good Drive&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintRight_toLeftOf=&quot;@+id/reviewTxt2&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt2&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginLeft=&quot;12dp&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Good Conversation&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintLeft_toRightOf=&quot;@+id/reviewTxt1&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/reviewRowTwoLayout&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;8dp&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/reviewRowThreeLayout&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/reviewRowOneLayout&quot;&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt3&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Nice Car&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintRight_toLeftOf=&quot;@+id/reviewTxt4&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt4&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginLeft=&quot;12dp&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Arrived Quickly&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintLeft_toRightOf=&quot;@+id/reviewTxt3&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/reviewRowThreeLayout&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;8dp&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/reviewRowFourLayout&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/reviewRowTwoLayout&quot;&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt5&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Good Vehicle&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintRight_toLeftOf=&quot;@+id/reviewTxt6&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt6&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginLeft=&quot;12dp&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:visibility=&quot;gone&quot;
                  android:text=&quot;Good Conversation&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintLeft_toRightOf=&quot;@+id/reviewTxt5&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/reviewRowFourLayout&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;8dp&quot;
              android:visibility=&quot;gone&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/reviewRowThreeLayout&quot;&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt7&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Good Drive&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintRight_toLeftOf=&quot;@+id/reviewTxt8&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/reviewTxt8&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginLeft=&quot;12dp&quot;
                  android:background=&quot;@drawable/edittext_border&quot;
                  android:padding=&quot;8dp&quot;
                  android:text=&quot;Good Conversation&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintLeft_toRightOf=&quot;@+id/reviewTxt7&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
          &lt;EditText
              android:id=&quot;@+id/taskRatingEdt&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/reviewRowFourLayout&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintBottom_toTopOf=&quot;@+id/submitTaskRatingBtn&quot;
              android:layout_marginTop=&quot;8dp&quot;
              android:hint=&quot;Leave a comment if you want...&quot;
              android:padding=&quot;13dp&quot;
              android:textSize=&quot;14dp&quot;
              android:layout_marginLeft=&quot;14dp&quot;
              android:layout_marginRight=&quot;14dp&quot;
              android:textColor=&quot;@color/black&quot;/&gt;
  
          &lt;Button
              android:id=&quot;@+id/submitTaskRatingBtn&quot;
              android:layout_width=&quot;170dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:background=&quot;@drawable/ripple_effect_send_green&quot;
              android:fontFamily=&quot;@font/axiforma_semi_bold&quot;
              android:padding=&quot;15dp&quot;
              android:text=&quot;@string/submit&quot;
              android:textAllCaps=&quot;false&quot;
              android:textColor=&quot;@color/light_black&quot;
              android:textSize=&quot;18sp&quot;
              android:layout_marginTop=&quot;8dp&quot;
              android:layout_marginBottom=&quot;12dp&quot;
              app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
              app:layout_constraintRight_toRightOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/taskRatingEdt&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot; /&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  </code></pre>
  <p>My output is:</p>
  <p><a href="https://i.stack.imgur.com/o8b4k.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8b4k.jpg" alt="enter image description here" /></a></p>
  <p>Where I want output like this:</p>
  <p><a href="https://i.stack.imgur.com/iflm9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iflm9.png" alt="enter image description here" /></a></p>
  <p>I want image on dialog box like this, half of its background should be invisible.</p>