Custom Dialog in full screen?

前端 未结 11 2051
终归单人心
终归单人心 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 13:54

    For full screen dialog you should extend DialogFragment it will provide Fragment life cycle methods and this is the recommended way in Android developer documents you can use simple Dialog or AlertDialog also.

    When you create dialog instance just use android.R.style.Theme_Black_NoTitleBar_Fullscreen theme with context like this :

    Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
    

    or

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
    

    This will show the dialog in full screen.

提交回复
热议问题