2021年1月15日星期五

Is there a way to enable immersive mode on material DatePicker?

I'm developing an app in which material DatePicker is used.

Material DatePicker Fragment from app

The entire application is fullscreen (immersive mode enabled - status and navigation bars are hidden) and I also want this in the DatePicker dialog. I've tried multiple suggestions but nothing worked. Is there a way to achieve this?

UPDATE:

What I've tried so far:

    val datePickerBuilder = MaterialDatePicker.Builder.dateRangePicker()        datePickerBuilder.apply {        setTitleText("SELECT A DATE")        setTheme(R.style.MaterialCalendarTheme)        setSelection(          Pair(            startDate.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(),            endDate.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(),          )        )      }          val dp = datePickerBuilder.build()        dp.dialog?.apply {        window?.setFlags(          WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,          WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE        )        window?.decorView?.setSystemUiVisibility(dp.requireActivity().window.decorView.getSystemUiVisibility())        setOnShowListener {          dp.dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)            val wm = dp.requireActivity().getSystemService(Context.WINDOW_SERVICE) as WindowManager          wm.updateViewLayout(dp.dialog?.window?.decorView, dp.dialog?.window?.attributes)        }      }  

The code snnipet from inside the second apply opperator works on other custom DialogFragmets that I've built.

After trying the above suggestion I've seen that the onCreateDialog method from MaterialDatePicker is final so an override is not possible.

https://stackoverflow.com/questions/65719724/is-there-a-way-to-enable-immersive-mode-on-material-datepicker January 14, 2021 at 09:17PM

没有评论:

发表评论