How to dismiss a DialogFragment when pressing outside the dialog?

前端 未结 8 625
盖世英雄少女心
盖世英雄少女心 2020-12-04 17:05

I am using a DialogFragment, and while I have successfully set an image to close (i.e. dismiss) the dialog when pressed, I am having a hard time finding the way

8条回答
  •  无人及你
    2020-12-04 18:05

                Dialog.SetCanceledOnTouchOutside(true);
    

    Worked for me
    My Code

    class dlgRegister : DialogFragment
            {
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
        ....
        ....
        }
        public override void OnActivityCreated(Bundle savedInstanceState)
                {
                    Dialog.Window.RequestFeature(WindowFeatures.NoTitle);
                    Dialog.SetCanceledOnTouchOutside(true);
                    base.OnActivityCreated(savedInstanceState);
                    Dialog.Window.Attributes.WindowAnimations =    Resource.Style.dialog_animation;
                }
        }
    

提交回复
热议问题