androiddialog

How to set custom dialog full screen? (android)


I want to show custom dialog in full screen. But It's not now. I don't know why.

This is my code

val dialog = Dialog(requireContext())
val view = LayoutInflater.from(activity).inflate(R.layout.custom, null)

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(view)
dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog.window?.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
dialog.window?.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
dialog.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY


Solution

  • Replace

    val dialog = Dialog(requireContext()) 
    

    with

    val dialog = Dialog(requireContext(), 
    android.R.style.Theme_Black_NoTitleBar_Fullscreen)