I'm creating the custom alert dialog box for this I create XML design using ConstraintLayout. The problem is that when I display the alert dialog box on the button click it some layout de from above and the bottom is not shown.
Here Is my XML layout.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/_500sdp">
<LinearLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginRight="@dimen/_16sdp"
android:background="@drawable/dialog_content_bg"
android:orientation="vertical"
tools:layout_editor_absoluteY="91dp"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_16sdp"
android:fontFamily="@font/quicksand_bold"
android:gravity="center"
android:paddingLeft="@dimen/_16sdp"
android:paddingTop="@dimen/_16sdp"
android:paddingRight="@dimen/_16sdp"
android:text="Did you collect the amount \nfrom customer ?"
android:textColor="@color/black"
android:textSize="@dimen/_16ssp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/_8sdp">
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_8sdp"
android:background="@drawable/ic_neg_btn"
android:text="Cancel"
android:textColor="@color/white" />
<androidx.appcompat.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_postive_btn"
android:text="Recieved"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/appBar"
app:layout_constraintTop_toTopOf="@+id/appBar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginBottom="@dimen/_16sdp"
android:src="@drawable/ic_error_bg" />
<ImageView
android:id="@+id/floatbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginBottom="@dimen/_16sdp"
android:src="@drawable/ic_error" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
And this is the function for displaying a custom alert dialog box.
btnDeliverOrder?.setOnClickListener {
if (onGoingOrdersModel?.txtPaymentMode?.equals("COD") == true) {
val inflater = requireActivity().layoutInflater
val view = inflater.inflate(R.layout.payment_paid_dialog, null)
val infoDialogBuilder = AlertDialog.Builder(activity)
infoDialogBuilder.setView(view)
val infoDialog = infoDialogBuilder.create()
infoDialog.setContentView(view)
infoDialog.show()
}else{
Toast.makeText(activity , "Paid" , Toast.LENGTH_SHORT).show()
}
}
Here I'm attaching the picture that can explain well what problem is occurring. https://firebasestorage.googleapis.com/v0/b/fir-application-8149d.appspot.com/o/WhatsApp%20Image%202022-02-14%20at%207.15.27%20AM.jpeg?alt=media&token=12469be5-b513-455d-99c1-abb5a9c8fe4c