hi I have to make a view like the below image .
But when i make the parent view transperent , default background is showing like this:
a transperent view is showing behind the main view.
my xml starts like :
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:layout_margin="@dimen/_8sdp"
android:background="@color/red"
android:clipChildren="false"
android:clipToPadding="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_50sdp"
android:background="@drawable/rounded_corner_shadow"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/progressLayout_frame"
android:layout_width="@dimen/_90sdp"
android:layout_height="@dimen/_90sdp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:clickable="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="@+id/bgCircle"
android:layout_width="@dimen/_70sdp"
android:layout_height="@dimen/_70sdp"
android:layout_gravity="center"
android:alpha="0.7"
android:background="@color/white"
android:visibility="visible" />
<RelativeLayout
android:id="@+id/progressLayout"
android:layout_width="@dimen/_80sdp"
android:layout_height="@dimen/_80sdp"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:clickable="true"
>
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="@dimen/_80sdp"
android:layout_height="@dimen/_80sdp"
android:layout_centerHorizontal="true"
android:background="@drawable/circle_shape"
android:progressDrawable="@drawable/circular_progress_bar" />
<TextView
android:id="@+id/tvTimeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="60dp"
android:text="00:00"
android:textColor="#FFFFFF"
android:textSize="29sp"
app:customTypeFace="roboto_light" />
how can I hide the view behind . why does this layout come ? any suggestions would be helpful . thanks in advance
To remove default background of the dialog...
Step 1:
Create a custom_dialog.xml
<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="wrap_content"
android:layout_marginHorizontal="@dimen/_20sdp"
android:paddingHorizontal="@dimen/_25sdp"
android:paddingVertical="@dimen/_25sdp" >
<androidx.constraintlayout.widget.Guideline
android:id="@+id/left_vertical_gl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.02" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/right_vertical_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.98" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/center_horizontal_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.48" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/top_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.044" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/end_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.90" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/segui_black"
android:text="Are You Sure?"
android:textColor="#484A67"
android:textSize="@dimen/_24ssp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_horizontal_gl" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_2sdp"
android:layout_marginBottom="12dp"
android:fontFamily="@font/segoe"
android:gravity="center"
android:text="Are you sure you want to sign out?"
android:textColor="#484A67"
android:textSize="@dimen/_11ssp"
app:layout_constraintEnd_toStartOf="@+id/right_vertical_gl"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView9" />
<TextView
android:id="@+id/yesTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_20sdp"
android:fontFamily="@font/segui_semi_bold"
android:padding="@dimen/_5sdp"
android:text="Yes"
android:textColor="#AD7BFF"
app:layout_constraintEnd_toStartOf="@+id/right_vertical_gl"
app:layout_constraintTop_toBottomOf="@+id/textView10" />
<TextView
android:id="@+id/noTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/_30sdp"
android:fontFamily="@font/segoe"
android:padding="@dimen/_5sdp"
android:text="No"
android:textColor="#6D6E85"
app:layout_constraintBottom_toBottomOf="@+id/yesTv"
app:layout_constraintEnd_toStartOf="@+id/yesTv"
app:layout_constraintTop_toTopOf="@+id/yesTv"
tools:layout_editor_absoluteX="143dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Step 2:
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
Complete code of the dialog
private lateinit var popUpDialog: Dialog
private fun buyLifeLineDialog() {
popUpDialog.setContentView(R.layout.dialog_buy_lifelines)
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
val yesTv = popUpDialog.findViewById<TextView>(R.id.yesTv);
val noTv = popUpDialog.findViewById<TextView>(R.id.noTv);
popUpDialog.show()
yesTv.setOnClickListener {
if (isCheatLl) {
mViewModel.buyCheatLifeline(index,lifeLinesPackagesModel)
}
else{
mViewModel.buyRespawnLifeline(index,lifeLinesPackagesModel)
}
popUpDialog.dismiss()
}
noTv.setOnClickListener {
popUpDialog.dismiss()
}
}