Full screen DialogFragment

前端 未结 10 2016
执笔经年
执笔经年 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:55

    You can also do something like-

    @Override
      public void onCreate(@Nullable final Bundle savedInstanceState) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
          setStyle(STYLE_NO_TITLE, android.R.style.Theme_Material_Light_NoActionBar_Fullscreen);
        } else {
          setStyle(STYLE_NO_TITLE, android.R.style.Theme_DeviceDefault_Light_NoActionBar);
        }
        super.onCreate(savedInstanceState);
    
      }
    

    By this you will also be able to see the status bar colored for versions >= lollipop

提交回复
热议问题