Create a destination from a full screen DialogFragment with Navigation component

136 views Asked by At

I'm using the navigation component. I didn't manage to use a dialog destination from a DialogFragment that is full screen.

I tried adding:

    <dialog
        android:id="@+id/fragment_mydialog"
        android:name="com.path.MyDialogFragment"
        tools:layout="@layout/layout_fragment_mydialog">

    </dialog>

and in the DialogFragment

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        setStyle(STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen);

        val dialog = Dialog(requireActivity())
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
        dialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialog.window!!.setLayout(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
        )
        return dialog
    }

    override fun onStart() {
        super.onStart()
        dialog?.window?.setLayout(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
        )
    }

The result is that the dialog is shown but it isn't full screen.

0

There are 0 answers