I've made custom layout for dialogFragment with rounded corners but when dialog is called corners are rounded he looks like below.
https://i.sstatic.net/rnlKJ.png
I know i need to set transparency dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
but I dont know where to put this in my code, additionally I'm using Kotlin.
Below is the part of code where Dialog is called.
myDialog = Event_Dialog.newInstance(args,args1)
myDialog.show(fragmentManager, "MyDialog")
This is Event_Dialog class.
class Event_Dialog : DialogFragment() {
companion object {
fun newInstance(bundle: String, bundle1: String): Event_Dialog {
//description
val args: Bundle = Bundle()
args.putString("desc", bundle)
//link
args.putString("link", bundle1)
val fragmentDialog = Event_Dialog()
fragmentDialog.arguments = args
return fragmentDialog
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val x = inflater.inflate(R.layout.event_detail, container, false)
some code.......
return x
Could you tell me guys where I should set the transparency of custom background ? Thanks !
just put it in oncreatedialog like :
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
return dialog
}
and i suggest that you use a framelayout as a root view for your dialog ( match parent frame ) and design your center layout in it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With