Full screen DialogFragment

前端 未结 10 2022
执笔经年
执笔经年 2021-02-04 02:26

I am trying to create a DialogFragment with a width of MATCH_PARENT so the dialog is nearly full screen (leaving the padding around the edges for the floating look). I have see

10条回答
  •  广开言路
    2021-02-04 02:54

    this is perfect for me. when extends DialogFragment override onCreateView()... impelments all logic

    dialog make it Full Screen just override this method

     @Override
    public Dialog onCreateDialog(final Bundle savedInstanceState) {
    
        // the content
        final RelativeLayout root = new RelativeLayout(getActivity());
        root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    
        // creating the fullscreen dialog
        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(root);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    
        return dialog;
    }
    

提交回复
热议问题