Custom Dialog in full screen?

前端 未结 11 2054
终归单人心
终归单人心 2020-12-08 13:35

Is there any way to make my Dialog view full screen, i.e dialog occupy the entire screen (like an Activity). I tried using the LayoutParams and styles like

11条回答
  •  死守一世寂寞
    2020-12-08 14:16

    The answer does not work for me(sdk 21, samsung galaxy s5). After searching and testing, I find that the key point for setting a dialog for fullscreen is the false in your dialog style. Most styles of Dialog in sdk set it true! Set it false in a style and use it in

    AlertDialog.Builder = new AlertDialog.Builder(getActivity(), R.style.YourStyle);
    

    your style may look like

    
    

    after setting it false, it should be fullscreen. And more, you can use

    dialog.getWindow.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    

    to set it's height to wrap_content. Hope to help someone.

提交回复
热议问题