DialogFragment fullscreen shows padding on sides

后端 未结 11 1596
囚心锁ツ
囚心锁ツ 2020-12-05 00:22

I am creating a custom DialogFragment that is displayed underneath the actionbar. So far everything works great. The layout parameters for dialog fragment are match_pa

11条回答
  •  一整个雨季
    2020-12-05 00:40

    The following works perfectly for me. It lets me have a full-width dialog (fills the screen's width with no padding) but with wrap_content for height, and it retains all my other stylings that I do in my builder:

    
    

    Background is required or else it does a weird repeat thing, but just set this to the color you want your dialog background to be. WindowBackground and WindowIsFloating are required to make the size wrap correctly.

    Add your theme to your builder like so:

    builder = new AlertDialog.Builder(_context, R.style.DialogTheme);
    

    and you're good to go!

提交回复
热议问题