Android Set Dialog Background Transparent (Kotlin)

April 13, 2019
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

Example

class BusyDialogFragment: DialogFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        // return super.onCreateView(inflater, container, savedInstanceState)

        // make white background transparent
        dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

        return activity!!.layoutInflater.inflate(R.layout.busy, container)
    }
}

NOTE: To remove dark overlay background, refer to Remove Dialog Black Overlay Background

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.