Transparent background for constraint layout in android not working

Viewed 31

Transparent background for constraint layout in android not working

I'm trying to make a custom android dialog with rounded corners. enter image description here

As you can see, the corners are rounded, but it leaves the white corner still intact.

2 Answers

If you using Fragment that extends with DialogFragment()

 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    requireDialog().window?.setBackgroundDrawableResource(R.drawable.white_curve_with_blue_outline)//you can use here the drawable
    requireDialog().window?.setBackgroundDrawable(ColorDrawable(Color.parseColor("#BF303030")))//you can use here the color/Transparent


}

Try this in your dialogue activity

yourDialogName.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
Related