Full screen DialogFragment

前端 未结 10 1999
执笔经年
执笔经年 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 03:01

    this answer help me How to set DialogFragment's width and height?

    int width = activity.getResources().getDisplayMetrics().widthPixels;
    int height = activity.getResources().getDisplayMetrics().heightPixels;
    content.setLayoutParams(new LinearLayout.LayoutParams(width, height));
    
    0 讨论(0)
  • 2021-02-04 03:05
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_TITLE,android.R.style.Theme_Holo_Light);
    }
    
    0 讨论(0)
  • 2021-02-04 03:07

    The best solution I found was to set the width or minWidth to some arbitrarily large value to ensure it fills the screen. I don't like this solution, but I haven't seen anything better.

    0 讨论(0)
  • 2021-02-04 03:07

    In my code, I was wanting a fullscreen dialog, but still show the notification bar at the top of the screen, so I'm using:

    setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar);
    

    This makes it fullscreen, but I'm not using a fullscreen style so that I keep the notification bar.

    Hope it helps someone!

    0 讨论(0)
提交回复
热议问题