Kotlin way to create dialog with transparent background:
Dialog(activity!!, R.style.LoadingIndicatorDialogStyle)
.apply {
// requestWindowFeature(Window.FEATURE_NO_TITLE)
setCancelable(true)
setContentView(R.layout.define_your_custom_view_id_here)
//access your custom view buttons/editText like below.z
val createBt = findViewById<TextView>(R.id.clipboard_create_project)
val cancelBt = findViewById<TextView>(R.id.clipboard_cancel_project)
val clipboard_et = findViewById<TextView>(R.id.clipboard_et)
val manualOption =
findViewById<TextView>(R.id.clipboard_manual_add_project_option)
//if you want to perform any operation on the button do like this
createBt.setOnClickListener {
//handle your button click here
val enteredData = clipboard_et.text.toString()
if (enteredData.isEmpty()) {
Utils.toast("Enter project details")
} else {
navigateToAddProject(enteredData, true)
dismiss()
}
}
cancelBt.setOnClickListener {
dismiss()
}
manualOption.setOnClickListener {
navigateToAddProject("", false)
dismiss()
}
show()
}
Create LoadingIndicatorDialogStyle in style.xml like this:
<style name="LoadingIndicatorDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:statusBarColor">@color/black_transperant</item>
<item name="android:layout_gravity">center</item>
<item name="android:background">@android:color/transparent</item>
<!--<item name="android:windowAnimationStyle">@style/MaterialDialogSheetAnimation</item>-->
</style>